├── .gitignore ├── README ├── build.js ├── buildAll.js ├── class ├── class.html ├── class.js ├── class_test.js └── qunit.html ├── controller ├── controller.html ├── controller.js ├── controller_test.js ├── demo-update.html ├── pages │ ├── listening.md │ └── plugin.md ├── qunit.html ├── route │ ├── qunit.html │ ├── route.html │ ├── route.js │ └── route_test.js ├── subscribe │ ├── funcunit.html │ ├── subscribe.html │ └── subscribe.js └── view │ ├── qunit.html │ ├── test │ └── qunit │ │ ├── controller_view_test.js │ │ ├── qunit.js │ │ └── views │ │ └── init.micro │ └── view.js ├── dom ├── closest │ └── closest.js ├── compare │ ├── compare.html │ ├── compare.js │ ├── compare_test.js │ └── qunit.html ├── cookie │ └── cookie.js ├── cur_styles │ ├── cur_styles.html │ ├── cur_styles.js │ ├── cur_styles_test.js │ ├── qunit.html │ └── test │ │ └── curStyles.micro ├── dimensions │ ├── dimensions.html │ ├── dimensions.js │ ├── dimensions_test.js │ ├── qunit.html │ └── test │ │ ├── curStyles.micro │ │ └── outer.micro ├── dom.js ├── fixture │ ├── fixture.html │ ├── fixture.js │ ├── fixture_test.js │ ├── fixtures │ │ ├── foo.json │ │ ├── foobar.json │ │ ├── messages.html │ │ ├── remove.json │ │ └── test.json │ └── qunit.html ├── form_params │ ├── form_params.html │ ├── form_params.js │ ├── form_params_test.js │ ├── qunit.html │ └── test │ │ ├── basics.micro │ │ ├── checkbox.micro │ │ ├── non-form.micro │ │ └── truthy.micro ├── range │ ├── qunit.html │ ├── range.html │ ├── range.js │ └── range_test.js ├── route │ ├── qunit.html │ ├── route.html │ ├── route.js │ └── route_test.js ├── selection │ ├── qunit.html │ ├── selection.html │ ├── selection.js │ └── selection_test.js └── within │ └── within.js ├── download ├── btn.png ├── download.css ├── download.html ├── download.js └── test │ ├── controllerpage.html │ ├── jquery-1.4.3.js │ └── run.js ├── event ├── default │ ├── default.html │ ├── default.js │ ├── default_pause_test.html │ ├── default_pause_test.js │ ├── default_test.js │ ├── defaultjquery.html │ └── qunit.html ├── destroyed │ ├── destroyed.html │ ├── destroyed.js │ ├── destroyed_menu.html │ ├── destroyed_test.js │ └── qunit.html ├── drag │ ├── drag.html │ ├── drag.js │ ├── drag_test.js │ ├── limit │ │ ├── limit.html │ │ └── limit.js │ ├── qunit.html │ ├── scroll │ │ └── scroll.js │ └── step │ │ ├── step.html │ │ └── step.js ├── drop │ ├── drop.html │ ├── drop.js │ └── drop_test.js ├── event.js ├── handle │ └── handle.js ├── hashchange │ └── hashchange.js ├── hover │ ├── hover.html │ ├── hover.js │ ├── hover_test.js │ └── qunit.html ├── key │ ├── key.html │ ├── key.js │ ├── key_test.js │ └── qunit.html ├── livehack │ └── livehack.js ├── pause │ ├── pause.html │ ├── pause.js │ ├── pause_test.js │ └── qunit.html ├── resize │ ├── demo.html │ ├── qunit.html │ ├── resize.html │ ├── resize.js │ └── resize_test.js ├── selection │ ├── qunit.html │ ├── selection.html │ ├── selection.js │ └── selection_test.js ├── swipe │ ├── qunit.html │ ├── swipe.html │ ├── swipe.js │ └── swipe_test.js └── tap │ ├── tap.html │ └── tap.js ├── generate ├── app ├── coffee │ ├── controller │ └── templates │ │ └── controller │ │ ├── (underscore).coffee.ejs │ │ ├── (underscore).html.ejs │ │ ├── (underscore)_test.coffee.ejs │ │ └── funcunit.html.ejs ├── controller ├── model ├── page ├── plugin ├── scaffold ├── templates │ ├── app │ │ ├── (application_name).css.ejs │ │ ├── (application_name).html.ejs │ │ ├── (application_name).js.ejs │ │ ├── (application_name).md.ejs │ │ ├── docs │ │ │ └── .ignore │ │ ├── fixtures │ │ │ ├── .ignore │ │ │ └── fixtures.js.ejs │ │ ├── funcunit.html.ejs │ │ ├── models │ │ │ ├── .ignore │ │ │ └── models.js.ejs │ │ ├── qunit.html.ejs │ │ ├── scripts │ │ │ ├── build.html.ejs │ │ │ ├── build.js.ejs │ │ │ ├── clean.js.ejs │ │ │ ├── crawl.js.ejs │ │ │ └── docs.js.ejs │ │ └── test │ │ │ ├── funcunit │ │ │ ├── (application_name)_test.js.ejs │ │ │ └── funcunit.js.ejs │ │ │ └── qunit │ │ │ ├── (application_name)_test.js.ejs │ │ │ └── qunit.js.ejs │ ├── controller │ │ ├── (underscore).html.ejs │ │ ├── (underscore).js.ejs │ │ ├── (underscore)_test.js.ejs │ │ ├── funcunit.html.ejs │ │ └── views │ │ │ ├── .ignore │ │ │ └── init.ejs.ejs │ ├── fixturemake.ejs │ ├── model.js │ ├── model │ │ ├── models │ │ │ └── (underscore).js.ejs │ │ └── test │ │ │ └── qunit │ │ │ └── (underscore)_test.js.ejs │ ├── page.ejs │ ├── plugin │ │ ├── (application_name).html.ejs │ │ ├── (application_name).js.ejs │ │ ├── (application_name)_test.js.ejs │ │ └── qunit.html.ejs │ ├── scaffold │ │ ├── create │ │ │ ├── create.html.ejs │ │ │ ├── create.js.ejs │ │ │ ├── create_test.js.ejs │ │ │ ├── funcunit.html.ejs │ │ │ └── views │ │ │ │ └── init.ejs.ejs │ │ └── list │ │ │ ├── funcunit.html.ejs │ │ │ ├── list.html.ejs │ │ │ ├── list.js.ejs │ │ │ ├── list_test.js.ejs │ │ │ └── views │ │ │ ├── (underscore).ejs.ejs │ │ │ └── init.ejs.ejs │ └── scaffoldHookup.ejs └── test │ ├── app_plugin_model_controller.js │ ├── run.js │ └── scaffold.js ├── jquery.js ├── jquerymx.md ├── lang ├── json │ └── json.js ├── lang_test.js ├── object │ ├── object.html │ ├── object.js │ ├── object_test.js │ └── qunit.html ├── observe │ ├── delegate │ │ ├── delegate.js │ │ └── delegate_test.js │ ├── demo.html │ ├── observe.html │ ├── observe.js │ ├── observe.md │ ├── observe_test.js │ └── qunit.html ├── openajax │ ├── openajax.html │ └── openajax.js ├── qunit.html ├── string │ ├── deparam │ │ ├── deparam.js │ │ ├── deparam_test.js │ │ └── qunit.html │ ├── qunit.html │ ├── rsplit │ │ └── rsplit.js │ ├── string.html │ ├── string.js │ └── string_test.js └── vector │ └── vector.js ├── model ├── backup │ ├── backup.html │ ├── backup.js │ ├── qunit.html │ └── qunit │ │ └── qunit.js ├── demo-convert.html ├── demo-dom.html ├── demo-encapsulate.html ├── demo-events.html ├── demo-setter.html ├── fixtures │ ├── school.json │ └── schools.json ├── list │ ├── cookie │ │ ├── cookie.html │ │ ├── cookie.js │ │ ├── qunit.html │ │ └── qunit │ │ │ └── qunit.js │ ├── list-insert.html │ ├── list.html │ ├── list.js │ ├── list_test.js │ ├── local │ │ └── local.js │ ├── memory.html │ └── qunit.html ├── model.js ├── modelBinder.html ├── pages │ ├── associations.html │ ├── deferreds.md │ ├── encapsulate.md │ └── typeconversion.md ├── qunit.html ├── service │ ├── json_rest │ │ └── json_rest.js │ ├── service.js │ ├── twitter │ │ ├── twitter.html │ │ └── twitter.js │ └── yql │ │ ├── yql.html │ │ └── yql.js ├── store │ ├── qunit.html │ ├── store.html │ ├── store.js │ └── store_test.js ├── test │ ├── 4.json │ ├── create.json │ ├── people.json │ ├── person.json │ ├── qunit │ │ ├── associations_test.js │ │ ├── findAll.json │ │ ├── model_test.js │ │ └── qunit.js │ ├── schools.json │ └── update4.json └── validations │ ├── demo.html │ ├── qunit.html │ ├── qunit │ └── validations_test.js │ ├── validations.html │ └── validations.js ├── qunit.html ├── test ├── qunit │ ├── integration.js │ └── qunit.js ├── run.js ├── template.ejs └── thing.json ├── tie ├── qunit.html ├── tie.html ├── tie.js └── tie_test.js ├── update └── view ├── compress.js ├── ejs ├── easyhookup.ejs ├── ejs.js ├── ejs_test.js ├── qunit.html └── test_template.ejs ├── fulljslint.js ├── helpers └── helpers.js ├── jaml └── jaml.js ├── micro └── micro.js ├── pages └── deferreds.md ├── qunit.html ├── test ├── compression │ ├── compression.html │ ├── compression.js │ ├── run.js │ └── views │ │ ├── keep.me │ │ └── test.ejs └── qunit │ ├── deferred.ejs │ ├── deferreds.ejs │ ├── hookup.ejs │ ├── hookupvalcall.ejs │ ├── large.ejs │ ├── nested_plugin.ejs │ ├── plugin.ejs │ ├── qunit.js │ ├── temp.ejs │ ├── template.ejs │ ├── template.jaml │ ├── template.micro │ ├── template.tmpl │ └── view_test.js ├── tmpl ├── test.tmpl ├── tmpl.js └── tmpl_test.js ├── view.html └── view.js /.gitignore: -------------------------------------------------------------------------------- 1 | .tmp* 2 | dist 3 | *.swp 4 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | TOC: 2 | A. How to get (and contribute) to JMVC 3 | 4 | 5 | A. How to get (and contribute) JMVC 6 | 7 | 1. Start a new project in git. 8 | 9 | 2. Fork .... 10 | http://github.com/jupiterjs/steal and 11 | http://github.com/jupiterjs/jquerymx 12 | 13 | 3. Add steal and jquerymx as submodules of your project... 14 | git submodule add git@github.com:_YOU_/steal.git steal 15 | git submodule add git@github.com:_YOU_/jquerymx.git jquery 16 | 17 | * Notice jquerymx is under the jquery folder 18 | 19 | 4. Learn a little more about submodules ... 20 | http://johnleach.co.uk/words/archives/2008/10/12/323/git-submodules-in-n-easy-steps 21 | 22 | 5. Make changes in steal or jquerymx, and push them back to your fork. 23 | 24 | 6. Make a pull request to your fork. 25 | 26 | -------------------------------------------------------------------------------- /class/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Class Test Suite

8 |

9 |
10 |

11 |
    12 |
    13 | 14 | 15 | -------------------------------------------------------------------------------- /controller/demo-update.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Controller Example 6 | 9 | 10 | 11 |
    12 |
    13 | 14 | 15 |
    16 |
    17 | 18 | 53 | 54 | -------------------------------------------------------------------------------- /controller/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 |

    Controller Test Suite

    14 |

    15 |
    16 |

    17 |
    18 |
      19 |
      20 | 21 | -------------------------------------------------------------------------------- /controller/route/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | route QUnit Test 6 | 7 | 8 | 9 | 10 |

      route Test Suite

      11 |

      12 |
      13 |

      14 |
      15 |
        16 |
        17 | 18 | -------------------------------------------------------------------------------- /controller/route/route.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | route 5 | 11 | 12 | 13 |

        route Demo

        14 | foo/bar 15 | foo/car 16 | empty 17 | 20 | 34 | 35 | -------------------------------------------------------------------------------- /controller/route/route.js: -------------------------------------------------------------------------------- 1 | steal('jquery/dom/route','jquery/controller', function(){ 2 | /** 3 | * 4 | * ":type route" // 5 | * 6 | * @param {Object} el 7 | * @param {Object} event 8 | * @param {Object} selector 9 | * @param {Object} cb 10 | */ 11 | jQuery.Controller.processors.route = function(el, event, selector, funcName, controller){ 12 | $.route(selector||"") 13 | var batchNum; 14 | var check = function(ev, attr, how){ 15 | if($.route.attr('route') === (selector||"") && 16 | (ev.batchNum === undefined || ev.batchNum !== batchNum ) ){ 17 | 18 | batchNum = ev.batchNum; 19 | 20 | var d = $.route.attrs(); 21 | delete d.route; 22 | 23 | controller[funcName](d) 24 | } 25 | } 26 | $.route.bind('change',check); 27 | return function(){ 28 | $.route.unbind('change',check) 29 | } 30 | } 31 | }) 32 | -------------------------------------------------------------------------------- /controller/route/route_test.js: -------------------------------------------------------------------------------- 1 | steal('funcunit/qunit','./route',function(){ 2 | 3 | module("route"); 4 | 5 | test("route testing works", function(){ 6 | ok(true,"an assert is run"); 7 | }); 8 | 9 | 10 | }); -------------------------------------------------------------------------------- /controller/subscribe/funcunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 |

        subscribe Test Suite

        14 |

        15 |
        16 |

        17 |
        18 |
          19 |
          20 | 21 | -------------------------------------------------------------------------------- /controller/subscribe/subscribe.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | hover 6 | 21 | 22 | 23 |
          24 |
          25 | subscribe me 26 |
          27 |

          Turn OFF Above

          28 |
          29 | 30 | 33 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /controller/subscribe/subscribe.js: -------------------------------------------------------------------------------- 1 | /*global OpenAjax: true */ 2 | steal('jquery/controller', 'jquery/lang/openajax').then(function() { 3 | 4 | /** 5 | * @function jQuery.Controller.static.processors.subscribe 6 | * @parent jQuery.Controller.static.processors 7 | * @plugin jquery/controller/subscribe 8 | * Adds OpenAjax.Hub subscribing to controllers. 9 | * 10 | * $.Controller("Subscriber",{ 11 | * "recipe.updated subscribe" : function(called, recipe){ 12 | * 13 | * }, 14 | * "todo.* subscribe" : function(called, todo){ 15 | * 16 | * } 17 | * }) 18 | * 19 | * You should typically be listening to jQuery triggered events when communicating between 20 | * controllers. Subscribe should be used for listening to model changes. 21 | * 22 | * ### API 23 | * 24 | * This is the call signiture for the processor, not the controller subscription callbacks. 25 | * 26 | * @param {HTMLElement} el the element being bound. This isn't used. 27 | * @param {String} event the event type (subscribe). 28 | * @param {String} selector the subscription name 29 | * @param {String} cb the callback function's name 30 | */ 31 | jQuery.Controller.processors.subscribe = function( el, event, selector, cb, controller ) { 32 | var subscription = OpenAjax.hub.subscribe(selector, function(){ 33 | return controller[cb].apply(controller, arguments) 34 | }); 35 | return function() { 36 | OpenAjax.hub.unsubscribe(subscription); 37 | }; 38 | }; 39 | 40 | /** 41 | * @add jQuery.Controller.prototype 42 | */ 43 | //breaker 44 | /** 45 | * @function publish 46 | * @hide 47 | * Publishes a message to OpenAjax.hub. 48 | * @param {String} message Message name, ex: "Something.Happened". 49 | * @param {Object} data The data sent. 50 | */ 51 | jQuery.Controller.prototype.publish = function() { 52 | OpenAjax.hub.publish.apply(OpenAjax.hub, arguments); 53 | }; 54 | }); -------------------------------------------------------------------------------- /controller/view/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 |

          Controller Test Suite

          14 |

          15 |
          16 |

          17 |
          18 |
            19 |
            20 | 21 | -------------------------------------------------------------------------------- /controller/view/test/qunit/controller_view_test.js: -------------------------------------------------------------------------------- 1 | steal('jquery/controller/view','jquery/view/micro','funcunit/qunit') //load qunit 2 | .then(function(){ 3 | 4 | module("jquery/controller/view"); 5 | 6 | test("this.view", function(){ 7 | 8 | $.Controller.extend("jquery.Controller.View.Test.Qunit",{ 9 | init: function() { 10 | this.element.html(this.view()) 11 | } 12 | }) 13 | jQuery.View.ext = ".micro"; 14 | $("#qunit-test-area").append("
            "); 15 | 16 | new jquery.Controller.View.Test.Qunit( $('#cont_view') ); 17 | 18 | ok(/Hello World/i.test($('#cont_view').text()),"view rendered") 19 | }); 20 | 21 | test("test.suffix.doubling", function(){ 22 | 23 | $.Controller.extend("jquery.Controller.View.Test.Qunit",{ 24 | init: function() { 25 | this.element.html(this.view('init.micro')) 26 | } 27 | }) 28 | 29 | jQuery.View.ext = ".ejs"; // Reset view extension to default 30 | equal(".ejs", jQuery.View.ext); 31 | 32 | $("#qunit-test-area").append("
            "); 33 | 34 | new jquery.Controller.View.Test.Qunit( $('#suffix_test_cont_view') ); 35 | 36 | ok(/Hello World/i.test($('#suffix_test_cont_view').text()),"view rendered") 37 | }); 38 | 39 | test("complex paths nested inside a controller directory", function(){ 40 | $.Controller.extend("Myproject.Controllers.Foo.Bar"); 41 | 42 | var path = jQuery.Controller._calculatePosition(Myproject.Controllers.Foo.Bar, "init.ejs", "init") 43 | equals(path, "//myproject/views/foo/bar/init.ejs", "view path is correct") 44 | 45 | $.Controller.extend("Myproject.Controllers.FooBar"); 46 | path = jQuery.Controller._calculatePosition(Myproject.Controllers.FooBar, "init.ejs", "init") 47 | equals(path, "//myproject/views/foo_bar/init.ejs", "view path is correct") 48 | }) 49 | }); 50 | 51 | -------------------------------------------------------------------------------- /controller/view/test/qunit/qunit.js: -------------------------------------------------------------------------------- 1 | //we probably have to have this only describing where the tests are 2 | steal('jquery/controller/view','jquery/view/micro') //load your app 3 | .then('funcunit/qunit') //load qunit 4 | .then("./controller_view_test.js") 5 | 6 | -------------------------------------------------------------------------------- /controller/view/test/qunit/views/init.micro: -------------------------------------------------------------------------------- 1 |

            Hello World

            -------------------------------------------------------------------------------- /dom/closest/closest.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @add jQuery.fn 3 | */ 4 | steal('jquery/dom').then(function(){ 5 | /** 6 | * @function closest 7 | * @parent dom 8 | * @plugin jquery/dom/closest 9 | * Overwrites closest to allow open > selectors. This allows controller 10 | * actions such as: 11 | * 12 | * ">li click" : function( el, ev ) { ... } 13 | */ 14 | var oldClosest = jQuery.fn.closest; 15 | jQuery.fn.closest = function(selectors, context){ 16 | var rooted = {}, res, result, thing, i, j, selector, rootedIsEmpty = true, selector, selectorsArr = selectors; 17 | if(typeof selectors == "string") selectorsArr = [selectors]; 18 | 19 | $.each(selectorsArr, function(i, selector){ 20 | if(selector.indexOf(">") == 0 ){ 21 | if(selector.indexOf(" ") != -1){ 22 | throw " closest does not work with > followed by spaces!" 23 | } 24 | rooted[( selectorsArr[i] = selector.substr(1) )] = selector; 25 | if(typeof selectors == "string") selectors = selector.substr(1); 26 | rootedIsEmpty = false; 27 | } 28 | }) 29 | 30 | res = oldClosest.call(this, selectors, context); 31 | 32 | if(rootedIsEmpty) return res; 33 | i =0; 34 | while(i < res.length){ 35 | result = res[i], selector = result.selector; 36 | if (rooted[selector] !== undefined) { 37 | result.selector = rooted[selector]; 38 | rooted[selector] = false; 39 | if(typeof result.selector !== "string" || result.elem.parentNode !== context ){ 40 | res.splice(i,1); 41 | continue; 42 | } 43 | } 44 | i++; 45 | } 46 | return res; 47 | } 48 | }) -------------------------------------------------------------------------------- /dom/compare/compare.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Compare Element Positions 6 | 34 | 35 | 36 |

            Click 2 elements to compare them.

            37 |
            38 | $('.red').compare($('.green')) = 
            39 | 
            40 |
            41 |
            42 | A 43 |
            A.1
            44 |
            A.2
            45 |
            46 |
            47 | B 48 |
            49 |
            50 |

            Key

            51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 |
            BitsNumberMeaning
            0000000Elements are identical.
            0000011The nodes are in different documents (or one is outside of a document).
            0000102Node B precedes Node A.
            0001004Node A precedes Node B.
            0010008Node B contains Node A.
            01000016Node A contains Node B.
            61 | 62 | 65 | 89 | 90 | -------------------------------------------------------------------------------- /dom/compare/compare_test.js: -------------------------------------------------------------------------------- 1 | steal("jquery/dom/compare") //load your app 2 | .then('funcunit/qunit').then(function(){ 3 | 4 | module("jquery/dom/compare") 5 | test("Compare cases", function(){ 6 | $(document.body).append("
            ") 7 | var outer = $("#outer"), 8 | first= outer.find(".first"), second = outer.find('.second') 9 | equals(outer.compare(outer) , 0, "identical elements") 10 | var outside = document.createElement("div") 11 | ok(outer.compare(outside) & 1, "different documents") 12 | 13 | equals(outer.compare(first), 20, "A container element"); 14 | equals(outer.compare(second), 20, "A container element"); 15 | 16 | equals(first.compare(outer), 10, "A parent element"); 17 | equals(second.compare(outer), 10, "A parent element"); 18 | 19 | equals(first.compare(second), 4, "A sibling elements"); 20 | equals(second.compare(first), 2, "A sibling elements"); 21 | outer.remove() 22 | }); 23 | 24 | }); -------------------------------------------------------------------------------- /dom/compare/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

            jQuery Dom Compare Test Suite

            13 |

            14 |
            15 |

            16 |
              17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /dom/cur_styles/cur_styles.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | CurStyles Performance Test/Demo 6 | 15 | 16 | 17 |

              CurStyles Performance

              18 |

              This demo shows how $.curStyles out-performs $.curCSS

              19 |
              20 |
              21 | Click To Run 22 |
              23 |
              24 | 26 | 27 | 28 | 68 | 69 | -------------------------------------------------------------------------------- /dom/cur_styles/cur_styles_test.js: -------------------------------------------------------------------------------- 1 | steal("jquery/dom/dimensions",'jquery/view/micro') //load your app 2 | .then('funcunit/qunit').then(function(){ 3 | 4 | module("jquery/dom/curStyles"); 5 | 6 | 7 | test("reading", function(){ 8 | 9 | $("#qunit-test-area").html("//jquery/dom/cur_styles/test/curStyles.micro",{}) 10 | 11 | var res = $.curStyles( $("#styled")[0], 12 | ["padding-left", 13 | 'position', 14 | 'display', 15 | "margin-top", 16 | "borderTopWidth", 17 | "float"] ); 18 | equals(res.borderTopWidth, "2px","border top"); 19 | equals(res.display, "block","display"); 20 | equals(res.cssFloat, "left","float"); 21 | equals(res.marginTop, "10px","margin top"); 22 | equals(res.paddingLeft, "5px","padding left"); 23 | equals(res.position, "relative","position"); 24 | $("#qunit-test-area").html("") 25 | }); 26 | 27 | }) 28 | 29 | -------------------------------------------------------------------------------- /dom/cur_styles/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | CurStyles Test Suite 4 | 5 | 10 | 11 | 12 | 13 | 14 |

              CurStyles Test Suite

              15 |

              16 |
              17 |

              18 |
              19 |
                20 |
                21 | 22 | -------------------------------------------------------------------------------- /dom/cur_styles/test/curStyles.micro: -------------------------------------------------------------------------------- 1 |
                2 | Here is some content; 3 |
                -------------------------------------------------------------------------------- /dom/dimensions/dimensions_test.js: -------------------------------------------------------------------------------- 1 | steal("jquery/dom/dimensions", 2 | 'jquery/view/micro', 3 | 'funcunit/qunit').then(function(){ 4 | 5 | module("jquery/dom/dimensions"); 6 | 7 | 8 | 9 | 10 | test("outerHeight and width",function(){ 11 | $("#qunit-test-area").html("//jquery/dom/dimensions/test/curStyles.micro",{}) 12 | }) 13 | 14 | }); -------------------------------------------------------------------------------- /dom/dimensions/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dimensions Test Suite 4 | 5 | 10 | 11 | 12 | 13 | 14 |

                Dimensions Test Suite

                15 |

                16 |
                17 |

                18 |
                19 |
                  20 |
                  21 | 22 | -------------------------------------------------------------------------------- /dom/dimensions/test/curStyles.micro: -------------------------------------------------------------------------------- 1 |
                  2 | Here is some content; 3 |
                  -------------------------------------------------------------------------------- /dom/dimensions/test/outer.micro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiterjs/jquerymx/0f917a85327a6c0196c2cf28c1d90a9095e0eae1/dom/dimensions/test/outer.micro -------------------------------------------------------------------------------- /dom/dom.js: -------------------------------------------------------------------------------- 1 | /** 2 | @page dom DOM Helpers 3 | @parent jquerymx 4 | @description jQuery DOM extension. 5 | 6 | JavaScriptMVC adds a bunch of useful 7 | jQuery extensions for the dom. Check them out on the left. 8 | 9 | ## [dimensions Dimensions] 10 | 11 | Set and animate the inner and outer height and width of elements. 12 | 13 | $('#foo').outerWidth(100); 14 | $('#bar').animate({innerWidth: 500}); 15 | 16 | This is great when you want to include padding and margin in 17 | setting the dimensions of elements. 18 | 19 | ## [jQuery.cookie Cookie] 20 | 21 | Set and get cookie values: 22 | 23 | $.cookie('cookie','value'); 24 | 25 | ## [jQuery.fixture Fixture] 26 | 27 | Simulate Ajax responses. 28 | 29 | $.fixture("/services/tasks.php','fixtures/tasks.json'); 30 | 31 | Works with jQuery's Ajax converters! 32 | 33 | ## [jQuery.fn.compare Compare] 34 | 35 | Compare the location of two elements rapidly. 36 | 37 | $('#foo').compare($('#bar')) & 2 // true if #bar is before #foo 38 | 39 | ## [jQuery.fn.curStyles CurStyles] 40 | 41 | Get multiple css properties quickly. 42 | 43 | $('#foo').curStyles('left','top') //-> {left:'20px',top:'10px'} 44 | 45 | ## [jQuery.fn.formParams FormParams] 46 | 47 | Serializes a form into a JSON-like object: 48 | 49 | $('form').formParams() //-> {name: 'Justin', favs: ['JS','Ruby']} 50 | 51 | ## [jQuery.fn.selection Selection] 52 | 53 | Gets or sets the current text selection. 54 | 55 | // gets selection info 56 | $('pre').selection() //-> {start: 22, end: 57, range: range} 57 | 58 | // sets the selection 59 | $('div').selection(20,22) 60 | 61 | ## [jQuery.fn.within Within] 62 | 63 | Returns elements that have a point within their boundaries. 64 | 65 | $('.drop').within(200,200) //-> drops that touch 200,200 66 | 67 | ## [jQuery.Range Range] 68 | 69 | Text range utilities. 70 | 71 | $('#copy').range() //-> text range that has copy selected 72 | 73 | ## [jQuery.route] 74 | 75 | Hash routes mapped to an [jQuery.Observe $.Observe]. 76 | 77 | $.route(':type',{type: 'videos'}) 78 | $.route.delegate('type','set', function(){ ... }) 79 | $.route.attr('type','images'); 80 | 81 | */ 82 | steal('jquery'); -------------------------------------------------------------------------------- /dom/fixture/fixtures/foo.json: -------------------------------------------------------------------------------- 1 | {"a" : "b"} 2 | -------------------------------------------------------------------------------- /dom/fixture/fixtures/foobar.json: -------------------------------------------------------------------------------- 1 | { 2 | "sweet" :"ner" 3 | } 4 | -------------------------------------------------------------------------------- /dom/fixture/fixtures/messages.html: -------------------------------------------------------------------------------- 1 | 2 |

                  Create a Message

                  3 |

                  Create a message, it will show up in "Get Messages".

                  4 |
                  5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
                  From:
                  Subject:
                  Body:
                  22 |
                  23 |

                  Get Messages

                  24 |

                  Enter a limit and offset to get a range of messages. 25 |

                  26 |
                  27 | Offset 28 | Limit 29 | 30 |
                  31 |
                  32 | -------------------------------------------------------------------------------- /dom/fixture/fixtures/remove.json: -------------------------------------------------------------------------------- 1 | { 2 | "weird" : "ness" 3 | } 4 | -------------------------------------------------------------------------------- /dom/fixture/fixtures/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "sweet" :"ness" 3 | } 4 | -------------------------------------------------------------------------------- /dom/fixture/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Fixtures Test Suite 4 | 5 | 10 | 11 | 12 | 13 | 14 |

                  Fixtures Test Suite

                  15 |

                  16 |
                  17 |

                  18 |
                  19 |
                    20 |
                    21 | 22 | -------------------------------------------------------------------------------- /dom/form_params/form_params.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Form Params 6 | 10 | 11 | 12 |

                    Change the inputs to change the object

                    13 |
                    Result = 
                    14 |
                    15 |
                    16 |
                    17 |
                    18 |
                    19 |
                    24 |
                    25 | 1 min
                    26 | 5 min
                    27 | 10 min
                    28 |
                    29 |
                    30 | 33 | 55 | 56 | -------------------------------------------------------------------------------- /dom/form_params/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form Params Test Suite 4 | 5 | 10 | 11 | 12 | 13 | 14 |

                    Fixtures Test Suite

                    15 |

                    16 |
                    17 |

                    18 |
                    19 |
                      20 |
                      21 | 22 | -------------------------------------------------------------------------------- /dom/form_params/test/basics.micro: -------------------------------------------------------------------------------- 1 |
                      2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
                      41 | -------------------------------------------------------------------------------- /dom/form_params/test/checkbox.micro: -------------------------------------------------------------------------------- 1 |
                      2 |
                      3 |
                      4 | 5 |
                      6 | 7 |
                      8 |
                      9 |
                      Reference
                      10 |
                      11 | 12 |
                      13 | 14 | 15 | 16 |
                      17 |
                      18 | 19 | 20 |
                      -------------------------------------------------------------------------------- /dom/form_params/test/non-form.micro: -------------------------------------------------------------------------------- 1 |
                      2 | 3 | 4 | 5 |
                      6 | -------------------------------------------------------------------------------- /dom/form_params/test/truthy.micro: -------------------------------------------------------------------------------- 1 |
                      2 | 3 | 4 | 5 | 6 | 7 |
                      -------------------------------------------------------------------------------- /dom/range/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Range QUnit Test 5 | 6 | 7 | 8 |

                      Range Test Suite

                      9 |

                      10 |
                      11 |

                      12 |
                      13 |
                        14 |
                        15 | 16 | 17 | -------------------------------------------------------------------------------- /dom/range/range.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Range 6 | 24 | 25 | 26 |
                        27 |

                        The Range Plugin

                        28 |

                        Select a range of text on the page and get useful info about it!

                        29 |

                        We'll figure out what to do with form elements later.

                        30 |
                        
                        31 | 		
                        32 | 36 | 65 | 66 | -------------------------------------------------------------------------------- /dom/route/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Jquery.Dom.Route FuncUnit Test 5 | 6 | 7 | 8 | 9 |

                        Jquery.Dom.Route Test Suite

                        10 |

                        11 |
                        12 |

                        13 |
                          14 | 15 | -------------------------------------------------------------------------------- /dom/selection/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | selection QUnit Test 5 | 8 | 9 | 10 | 11 | 12 |

                          selection Test Suite

                          13 |

                          14 |
                          15 |

                          16 |
                          17 |
                            18 |
                            19 | 20 | -------------------------------------------------------------------------------- /dom/selection/selection.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | selection 6 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 33 | 34 | 35 |
                            Select Textarea
                            Select Input
                            Select Within One Element

                            0123456789

                            Select Across Multiple Elements
                            012
                            345
                            36 | 38 | 55 | 56 | -------------------------------------------------------------------------------- /dom/selection/selection_test.js: -------------------------------------------------------------------------------- 1 | steal("funcunit/qunit", "jquery/dom/selection").then(function(){ 2 | 3 | module("jquery/dom/selection"); 4 | 5 | test("getCharElement", function(){ 6 | $("#qunit-test-area") 7 | .html(""+ 8 | ""+ 9 | "

                            0123456789

                            "+ 10 | "
                            012
                            345
                            "); 11 | stop(); 12 | setTimeout(function(){ 13 | var types = ['textarea','#inp','#1','#2']; 14 | for(var i =0; i< types.length; i++){ 15 | //console.log(types[i]) 16 | $(types[i]).selection(1,5); 17 | } 18 | /* 19 | $('textarea').selection(1,5); 20 | $('input').selection(1,5); 21 | $('#1').selection(1,5); 22 | $('#2').selection(1,5); 23 | */ 24 | var res = []; 25 | for(var i =0; i< types.length; i++){ 26 | res.push( $(types[i]).selection() ); 27 | } 28 | 29 | 30 | 31 | for(var i =0; i< res.length; i++){ 32 | same(res[i],{start: 1, end: 5},types[i]) 33 | } 34 | 35 | start(); 36 | },1000) 37 | }); 38 | 39 | }); -------------------------------------------------------------------------------- /dom/within/within.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @add jQuery.fn 3 | */ 4 | steal('jquery/dom').then(function($){ 5 | var withinBox = function(x, y, left, top, width, height ){ 6 | return (y >= top && 7 | y < top + height && 8 | x >= left && 9 | x < left + width); 10 | } 11 | /** 12 | * @function within 13 | * @parent dom 14 | * @plugin jquery/dom/within 15 | * 16 | * Returns the elements are within the position. 17 | * 18 | * // get all elements that touch 200x200. 19 | * $('*').within(200, 200); 20 | * 21 | * @param {Number} left the position from the left of the page 22 | * @param {Number} top the position from the top of the page 23 | * @param {Boolean} [useOffsetCache] cache the dimensions and offset of the elements. 24 | * @return {jQuery} a jQuery collection of elements whos area 25 | * overlaps the element position. 26 | */ 27 | $.fn.within= function(left, top, useOffsetCache) { 28 | var ret = [] 29 | this.each(function(){ 30 | var q = jQuery(this); 31 | 32 | if (this == document.documentElement) { 33 | return ret.push(this); 34 | } 35 | var offset = useOffsetCache ? 36 | jQuery.data(this,"offsetCache") || jQuery.data(this,"offsetCache", q.offset()) : 37 | q.offset(); 38 | 39 | var res = withinBox(left, top, offset.left, offset.top, 40 | this.offsetWidth, this.offsetHeight ); 41 | 42 | if (res) { 43 | ret.push(this); 44 | } 45 | }); 46 | 47 | return this.pushStack( jQuery.unique( ret ), "within", left+","+top ); 48 | } 49 | 50 | 51 | /** 52 | * @function withinBox 53 | * @parent jQuery.fn.within 54 | * returns if elements are within the box 55 | * @param {Object} left 56 | * @param {Object} top 57 | * @param {Object} width 58 | * @param {Object} height 59 | * @param {Object} cache 60 | */ 61 | $.fn.withinBox = function(left, top, width, height, cache){ 62 | var ret = [] 63 | this.each(function(){ 64 | var q = jQuery(this); 65 | 66 | if(this == document.documentElement) return this.ret.push(this); 67 | 68 | var offset = cache ? 69 | jQuery.data(this,"offset") || 70 | jQuery.data(this,"offset", q.offset()) : 71 | q.offset(); 72 | 73 | 74 | var ew = q.width(), eh = q.height(); 75 | 76 | res = !( (offset.top > top+height) || (offset.top +eh < top) || (offset.left > left+width ) || (offset.left+ew < left)); 77 | 78 | if(res) 79 | ret.push(this); 80 | }); 81 | return this.pushStack( jQuery.unique( ret ), "withinBox", jQuery.makeArray(arguments).join(",") ); 82 | } 83 | 84 | }) -------------------------------------------------------------------------------- /download/btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiterjs/jquerymx/0f917a85327a6c0196c2cf28c1d90a9095e0eae1/download/btn.png -------------------------------------------------------------------------------- /download/download.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0px; padding: 0px; 3 | overflow: hidden; 4 | } 5 | #plugins .dl_btn_container{ 6 | background: url(btn.png); 7 | border: none; 8 | color: #fff; 9 | font-size: 2em; 10 | float: right; 11 | line-height: 56px; 12 | margin: 20px; 13 | height: 55px; 14 | text-align: center; 15 | width: 171px; 16 | } 17 | 18 | #plugins .dl_btn_container:hover{ 19 | color: #bbb; 20 | cursor: pointer 21 | } 22 | 23 | #plugins #pluginForm { 24 | border-top: dotted 1px #000; 25 | padding: 0px; 26 | width: 100%; 27 | overflow: auto; 28 | } 29 | 30 | #plugins .section{ 31 | clear: both; 32 | overflow: auto; 33 | border-bottom: dotted 1px #000; 34 | padding: 16px 16px 18px; 35 | 36 | background: #eee; 37 | } 38 | 39 | #plugins .section .section-desc{ 40 | float: left; 41 | width: 125px; 42 | } 43 | 44 | #plugins .section .section-desc h3{ 45 | font-size: 1.0em; 46 | margin: 0px 0px 6px; 47 | } 48 | 49 | #plugins .section .section-desc p{ 50 | font-size: 0.7em; 51 | } 52 | 53 | #plugins .plugin{ 54 | float: right; 55 | padding: 0px; 56 | overflow: auto; 57 | width: 422px; 58 | 59 | } 60 | 61 | #plugins .plugin input { 62 | float:left; 63 | } 64 | 65 | #plugins .plugin label{ 66 | color: #5387BD; 67 | display: block; 68 | float: left; 69 | font-size: 0.7em; 70 | font-weight: bold; 71 | margin-left: 10px; 72 | width: 175px; 73 | word-wrap: break-word; 74 | } 75 | 76 | #plugins .plugin .desc{ 77 | float: left; 78 | font-size: 0.7em; 79 | margin: 0px 0px 0px 20px; 80 | width: 194px; 81 | } 82 | 83 | #plugins .select-all-container{ 84 | text-align: right; 85 | font-size: 0.7em; 86 | font-weight: bold; 87 | margin: 0px 6px 12px 0px; 88 | } -------------------------------------------------------------------------------- /download/test/controllerpage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | -------------------------------------------------------------------------------- /download/test/run.js: -------------------------------------------------------------------------------- 1 | // load('steal/compress/test/run.js') 2 | /** 3 | * Tests compressing a very basic page and one that is using steal 4 | */ 5 | load('steal/rhino/rhino.js') 6 | steal('steal/test', function( s ) { 7 | STEALPRINT = false; 8 | s.test.module("jquery/download") 9 | 10 | s.test.test("controller", function(){ 11 | load('steal/rhino/rhino.js') 12 | s.test.open('jquery/download/test/controllerpage.html') 13 | s.test.ok(MyController, "Controller was loaded") 14 | s.test.clear(); 15 | }); 16 | }); -------------------------------------------------------------------------------- /event/default/default.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | default 6 | 29 | 30 | 31 | 32 |

                            Default Events

                            33 |

                            A tabs widget that doesn't let you continue until the first part is complete.

                            34 |
                            35 |
                            36 | 40 |
                            41 | Check to complete this part. 42 |
                            43 |
                            44 | You completed part 1 45 |
                            46 |
                            47 |
                            48 | 49 | 50 | 53 | 87 | 88 | -------------------------------------------------------------------------------- /event/default/default_pause_test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Default Test Suite 4 | 5 | 10 | 11 | 12 | 13 | 14 |

                            Default Test Suite

                            15 |

                            16 |
                            17 |

                            18 |
                            19 |
                              20 |
                              21 | 22 | -------------------------------------------------------------------------------- /event/default/default_pause_test.js: -------------------------------------------------------------------------------- 1 | steal('funcunit/qunit','jquery/event/default','jquery/event/pause').then(function(){ 2 | 3 | module("jquery/event/default_pause"); 4 | 5 | 6 | test("default and pause with delegate", function(){ 7 | var order = []; 8 | stop(); 9 | $("#qunit-test-area").html("

                              hello

                              ") 10 | 11 | $("#foo").delegate("#bar","default.show", function(){ 12 | order.push("default") 13 | }); 14 | 15 | $("#foo").delegate("#bar","show", function(ev){ 16 | order.push('show') 17 | ev.pause(); 18 | 19 | setTimeout(function(){ 20 | ev.resume(); 21 | 22 | setTimeout(function(){ 23 | start(); 24 | same(order,['show','default']) 25 | },30) 26 | 27 | },50) 28 | }); 29 | 30 | 31 | $("#bar").trigger("show") 32 | 33 | }); 34 | 35 | test("default and pause with live", function(){ 36 | $("#qunit-test-area").html("
                              hello
                              ") 37 | 38 | var order = []; 39 | stop(); 40 | 41 | $("#foo").live("default.show", function(){ 42 | order.push("default") 43 | }); 44 | $("#foo").live("show", function(ev){ 45 | order.push('show') 46 | ev.pause(); 47 | setTimeout(function(){ 48 | ev.resume(); 49 | setTimeout(function(){ 50 | start(); 51 | same(order,['show','default']) 52 | $("#foo").die("show"); 53 | $("#foo").die("default.show"); 54 | },30) 55 | },50) 56 | }); 57 | 58 | 59 | $("#foo").trigger("show") 60 | 61 | }); 62 | 63 | 64 | test("triggerAsync", function(){ 65 | $("#qunit-test-area").html("
                              hello
                              ") 66 | 67 | var order = []; 68 | stop(); 69 | 70 | $("#foo").live("default.show", function(){ 71 | order.push("default") 72 | }); 73 | 74 | $("#foo").live("show", function(ev){ 75 | order.push('show') 76 | ev.pause(); 77 | setTimeout(function(){ 78 | ev.resume(); 79 | setTimeout(function(){ 80 | start(); 81 | $("#foo").die() 82 | same(order,['show','default','async']) 83 | },30) 84 | },50) 85 | }); 86 | 87 | 88 | $("#foo").triggerAsync("show", function(){ 89 | order.push("async") 90 | }) 91 | }); 92 | 93 | test("triggerAsync with nothing", function(){ 94 | $("#fool").triggerAsync("show", function(){ 95 | ok(true) 96 | }) 97 | }); 98 | 99 | 100 | }); -------------------------------------------------------------------------------- /event/default/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Default Test Suite 4 | 5 | 10 | 11 | 12 | 13 | 14 |

                              Default Test Suite

                              15 |

                              16 |
                              17 |

                              18 |
                              19 |
                                20 |
                                21 | 22 | -------------------------------------------------------------------------------- /event/destroyed/destroyed.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | destroyed demo 5 | 6 | 7 | 8 |
                                9 |
                                Click Below to destroy me
                                10 | Click here!
                                11 |
                                12 | 13 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /event/destroyed/destroyed.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @add jQuery.event.special 3 | */ 4 | steal('jquery/event').then(function( $ ) { 5 | /** 6 | * @attribute destroyed 7 | * @parent specialevents 8 | * @download http://jmvcsite.heroku.com/pluginify?plugins[]=jquery/dom/destroyed/destroyed.js 9 | * @test jquery/event/destroyed/qunit.html 10 | * Provides a destroyed event on an element. 11 | *

                                12 | * The destroyed event is called when the element 13 | * is removed as a result of jQuery DOM manipulators like remove, html, 14 | * replaceWith, etc. Destroyed events do not bubble, so make sure you don't use live or delegate with destroyed 15 | * events. 16 | *

                                17 | *

                                Quick Example

                                18 | * @codestart 19 | * $(".foo").bind("destroyed", function(){ 20 | * //clean up code 21 | * }) 22 | * @codeend 23 | *

                                Quick Demo

                                24 | * @demo jquery/event/destroyed/destroyed.html 25 | *

                                More Involved Demo

                                26 | * @demo jquery/event/destroyed/destroyed_menu.html 27 | */ 28 | 29 | var oldClean = jQuery.cleanData; 30 | 31 | $.cleanData = function( elems ) { 32 | for ( var i = 0, elem; 33 | (elem = elems[i]) !== undefined; i++ ) { 34 | $(elem).triggerHandler("destroyed"); 35 | //$.event.remove( elem, 'destroyed' ); 36 | } 37 | oldClean(elems); 38 | }; 39 | 40 | }); -------------------------------------------------------------------------------- /event/destroyed/destroyed_test.js: -------------------------------------------------------------------------------- 1 | steal("jquery/event/destroyed") //load your app 2 | .then('funcunit/qunit') 3 | .then(function(){ 4 | 5 | module("jquery/event/destroyed") 6 | test("removing an element", function(){ 7 | var div = $("
                                ").data("testData",5) 8 | div.appendTo($("#qunit-test-area")) 9 | var destroyed = false; 10 | div.bind("destroyed",function(){ 11 | destroyed = true; 12 | equals($(this).data("testData"),5, "other data still exists") 13 | }) 14 | div.remove(); 15 | ok(destroyed, "destroyed called") 16 | }); 17 | 18 | }); -------------------------------------------------------------------------------- /event/destroyed/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 |

                                destroyed Test Suite

                                14 |

                                15 |
                                16 |

                                17 |
                                18 |
                                  19 |
                                  20 | 21 | -------------------------------------------------------------------------------- /event/drag/limit/limit.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | drag 6 | 30 | 31 | 32 |
                                  33 |
                                  handle
                                  34 |
                                  handle
                                  35 |
                                  36 | 37 |
                                  38 |
                                  handle
                                  39 |
                                  handle
                                  40 |
                                  41 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /event/drag/limit/limit.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @add jQuery.Drag.prototype 3 | */ 4 | 5 | steal('jquery/event/drag', 'jquery/dom/cur_styles').then(function( $ ) { 6 | 7 | 8 | $.Drag.prototype 9 | /** 10 | * @function limit 11 | * @plugin jquery/event/drag/limit 12 | * @download http://jmvcsite.heroku.com/pluginify?plugins[]=jquery/event/event/drag/limit/limit.js 13 | * limits the drag to a containing element 14 | * @param {jQuery} container 15 | * @param {Object} [center] can set the limit to the center of the object. Can be 16 | * 'x', 'y' or 'both' 17 | * @return {$.Drag} 18 | */ 19 | .limit = function( container, center ) { 20 | //on draws ... make sure this happens 21 | var styles = container.curStyles('borderTopWidth', 'paddingTop', 'borderLeftWidth', 'paddingLeft'), 22 | paddingBorder = new $.Vector( 23 | parseInt(styles.borderLeftWidth, 10) + parseInt(styles.paddingLeft, 10) || 0, parseInt(styles.borderTopWidth, 10) + parseInt(styles.paddingTop, 10) || 0); 24 | 25 | this._limit = { 26 | offset: container.offsetv().plus(paddingBorder), 27 | size: container.dimensionsv(), 28 | center : center === true ? 'both' : center 29 | }; 30 | return this; 31 | }; 32 | 33 | var oldPosition = $.Drag.prototype.position; 34 | $.Drag.prototype.position = function( offsetPositionv ) { 35 | //adjust required_css_position accordingly 36 | if ( this._limit ) { 37 | var limit = this._limit, 38 | center = limit.center && limit.center.toLowerCase(), 39 | movingSize = this.movingElement.dimensionsv('outer'), 40 | halfHeight = center && center != 'x' ? movingSize.height() / 2 : 0, 41 | halfWidth = center && center != 'y' ? movingSize.width() / 2 : 0, 42 | lot = limit.offset.top(), 43 | lof = limit.offset.left(), 44 | height = limit.size.height(), 45 | width = limit.size.width(); 46 | 47 | //check if we are out of bounds ... 48 | //above 49 | if ( offsetPositionv.top()+halfHeight < lot ) { 50 | offsetPositionv.top(lot - halfHeight); 51 | } 52 | //below 53 | if ( offsetPositionv.top() + movingSize.height() - halfHeight > lot + height ) { 54 | offsetPositionv.top(lot + height - movingSize.height() + halfHeight); 55 | } 56 | //left 57 | if ( offsetPositionv.left()+halfWidth < lof ) { 58 | offsetPositionv.left(lof - halfWidth); 59 | } 60 | //right 61 | if ( offsetPositionv.left() + movingSize.width() -halfWidth > lof + width ) { 62 | offsetPositionv.left(lof + width - movingSize.left()+halfWidth); 63 | } 64 | } 65 | 66 | oldPosition.call(this, offsetPositionv); 67 | }; 68 | 69 | }); -------------------------------------------------------------------------------- /event/drag/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                  Drag/Drop Test Suite

                                  8 |

                                  9 |
                                  10 |

                                  11 |
                                    12 |
                                    13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /event/drag/step/step.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | drag 6 | 36 | 37 | 38 | 39 |
                                    40 |
                                    41 |
                                    top left
                                    42 |
                                    horizontal
                                    43 |
                                    vertical
                                    44 |
                                    horizontal vertical
                                    45 |
                                    46 |
                                    47 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /event/drop/drop.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | drop 6 | 28 | 29 | 30 |
                                    43 | 45 | 74 | 75 | -------------------------------------------------------------------------------- /event/drop/drop_test.js: -------------------------------------------------------------------------------- 1 | steal('funcunit','funcunit/syn').then(function(){ 2 | 3 | module("jquery/event/drop"); 4 | 5 | test("new drop added",2, function(){ 6 | var div = $("
                                    "+ 7 | "
                                    "+ 8 | "
                                    "+ 9 | "
                                    "+ 10 | "
                                    "); 11 | 12 | div.appendTo($("#qunit-test-area")); 13 | var basicCss = { 14 | width: "20px", 15 | height: "20px", 16 | position: "absolute", 17 | border: "solid 1px black" 18 | } 19 | $("#drag").css(basicCss).css({top: "0px", left: "0px", zIndex: 1000, backgroundColor: "red"}) 20 | $("#midpoint").css(basicCss).css({top: "0px", left: "30px"}) 21 | $("#drop").css(basicCss).css({top: "0px", left: "60px"}); 22 | 23 | $('#drag').bind("draginit", function(){}); 24 | 25 | $("#midpoint").bind("dropover",function(){ 26 | ok(true, "midpoint called"); 27 | 28 | $("#drop").bind("dropover", function(){ 29 | ok(true, "drop called"); 30 | }); 31 | $.Drop.compile(); 32 | }); 33 | stop(); 34 | Syn.drag({to: "#drop"},"drag", function(){ 35 | start(); 36 | }); 37 | }); 38 | 39 | 40 | 41 | }) 42 | -------------------------------------------------------------------------------- /event/event.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @page specialevents Special Events 3 | * @parent jquerymx 4 | * @description Special events like drag-drop. 5 | * 6 | * JavaScriptMVC provides a bunch of useful special events. Find out more info on the left. The following is a 7 | * brief summary: 8 | * 9 | * ## [jQuery.event.special.default Default Events] 10 | * 11 | * Lets you supply default behavior for an event that is preventable 12 | * with event.preventDefault(). This is extremely useful for providing DOM-like api's for your widgets. 13 | * 14 | * $("#tabs").delegate(".panel","default.open", function(){ 15 | * $(this).show() 16 | * }) 17 | * 18 | * ## [jQuery.event.special.destroyed Destroyed Events] 19 | * 20 | * Know if an element has been removed from the page. 21 | * 22 | * $("#contextMenu").bind("destroyed", function(){ 23 | * // cleanup 24 | * $(document.body).unbind("click.contextMenu"); 25 | * }) 26 | * 27 | * ## [jQuery.Drag Drag] and [jQuery.Drop Drop] Events 28 | * 29 | * Listen to drag-drop events with event delegation. 30 | * 31 | * $(".item").live("dragover", function(ev, drag){ 32 | * // let user know that the item can be dropped 33 | * $(this).addClass("canDrop"); 34 | * }).live("dropover", function(ev, drop, drag){ 35 | * // let user know that the item can be dropped on 36 | * $(this).addClass('drop-able') 37 | * }) 38 | * 39 | * ## 40 | * 41 | */ 42 | steal('jquery'); -------------------------------------------------------------------------------- /event/hover/hover.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | hover 6 | 22 | 23 | 24 |
                                    25 |

                                    Delegating

                                    26 |
                                    hover me
                                    27 |
                                    hover me
                                    28 |

                                    Bound Directly

                                    29 |
                                    hover me for a second
                                    30 |
                                    hover me for a second
                                    31 |

                                    HoverLeave

                                    32 |
                                    Leave and don't return for a half second
                                    33 |
                                    34 | 36 | 37 | 69 | 70 | -------------------------------------------------------------------------------- /event/hover/hover_test.js: -------------------------------------------------------------------------------- 1 | steal("jquery/event/hover",'funcunit/syn') //load your app 2 | .then('funcunit/qunit') 3 | .then(function(){ 4 | 5 | module("jquery/dom/hover") 6 | 7 | test("hovering", function(){ 8 | $("#qunit-test-area").append("
                                    Content
                                    ") 9 | var hoverenters = 0, 10 | hoverinits = 0, 11 | hoverleaves = 0, 12 | delay = 15; 13 | $("#hover").bind("hoverinit", function(ev, hover){ 14 | hover.delay(delay); 15 | hoverinits++; 16 | }) 17 | .bind('hoverenter', function(){ 18 | hoverenters++; 19 | }) 20 | .bind('hoverleave',function(){ 21 | hoverleaves++; 22 | }) 23 | var hover = $("#hover") 24 | var off = hover.offset(); 25 | 26 | //add a mouseenter, and 2 mouse moves 27 | Syn("mouseover",{pageX: off.top, pageY: off.left}, hover[0]) 28 | ok(hoverinits, 'hoverinit'); 29 | ok(hoverenters === 0,"hoverinit hasn't been called"); 30 | stop(); 31 | 32 | setTimeout(function(){ 33 | ok(hoverenters === 1,"hoverenter has been called"); 34 | 35 | ok(hoverleaves === 0,"hoverleave hasn't been called"); 36 | Syn("mouseout",{pageX: off.top, pageY: off.left},hover[0]); 37 | 38 | ok(hoverleaves === 1,"hoverleave has been called"); 39 | 40 | delay = 30; 41 | 42 | Syn("mouseover",{pageX: off.top, pageY: off.left},hover[0]); 43 | ok(hoverinits === 2, 'hoverinit'); 44 | 45 | setTimeout(function(){ 46 | 47 | Syn("mouseout",{pageX: off.top, pageY: off.left},hover[0]); 48 | 49 | 50 | setTimeout(function(){ 51 | ok(hoverenters === 1,"hoverenter was not called"); 52 | ok(hoverleaves === 1,"hoverleave was not called"); 53 | start(); 54 | },30) 55 | 56 | },10) 57 | 58 | },30) 59 | }); 60 | 61 | }); 62 | -------------------------------------------------------------------------------- /event/hover/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

                                    Hover Test Suite

                                    9 |

                                    10 |
                                    11 |

                                    12 |
                                    13 |
                                      14 |
                                      15 | 16 | -------------------------------------------------------------------------------- /event/key/key.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | jQuery Event Key 6 | 9 | 10 | 11 |
                                      12 | 13 |
                                      Keydown:
                                      14 |
                                      Keypress:
                                      15 |
                                      Keyup:
                                      16 |
                                      17 | 31 | 32 | -------------------------------------------------------------------------------- /event/key/key_test.js: -------------------------------------------------------------------------------- 1 | steal('funcunit/qunit','funcunit/syn','jquery/event/key').then(function(){ 2 | 3 | module('jquery/event/key'); 4 | 5 | test("type some things", function(){ 6 | $("#qunit-test-area").append("") 7 | var keydown, keypress, keyup; 8 | $('#key').keydown(function(ev){ 9 | keydown = ev.keyName(); 10 | }).keypress(function(ev){ 11 | keypress = ev.keyName(); 12 | }).keyup(function(ev){ 13 | keyup = ev.keyName(); 14 | }); 15 | 16 | stop(); 17 | 18 | Syn.key("a","key", function(){ 19 | equals(keydown, "a","keydown"); 20 | equals(keypress,"a","keypress"); 21 | equals(keyup, "a","keyup"); 22 | start(); 23 | }); 24 | }) 25 | 26 | }) 27 | -------------------------------------------------------------------------------- /event/key/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

                                      Key Test Suite

                                      9 |

                                      10 |
                                      11 |

                                      12 |
                                      13 |
                                        14 |
                                        15 | 16 | -------------------------------------------------------------------------------- /event/pause/pause_test.js: -------------------------------------------------------------------------------- 1 | steal('funcunit/qunit','funcunit/syn','jquery/event/pause').then(function(){ 2 | 3 | module("jquery/event/pause", {setup : function(){ 4 | $("#qunit-test-area").html("") 5 | var div = $("
                                          "+ 6 | "
                                        • Hello

                                          "+ 7 | "
                                          • Foo Bar

                                          "+ 8 | "
                                        ").appendTo($("#qunit-test-area")); 9 | 10 | }}); 11 | 12 | test("basics",3, function(){ 13 | 14 | var calls =0, 15 | lastTime, 16 | space = function(){ 17 | if(lastTime){ 18 | 19 | ok(new Date - lastTime > 35,"space between times "+(new Date - lastTime)) 20 | } 21 | lastTime = new Date() 22 | }; 23 | 24 | $('#ul').delegate("li", "show",function(ev){ 25 | calls++; 26 | space(); 27 | 28 | ev.pause(); 29 | 30 | setTimeout(function(){ 31 | ev.resume(); 32 | },100) 33 | 34 | }) 35 | 36 | $('#wrapper').bind('show', function(){ 37 | space() 38 | equals(calls, 2, "both lis called"); 39 | start() 40 | }); 41 | stop(); 42 | $('#foo').trigger("show") 43 | }); 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | }); -------------------------------------------------------------------------------- /event/pause/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | swipe QUnit Test 5 | 8 | 9 | 10 | 11 | 12 |

                                        swipe Test Suite

                                        13 |

                                        14 |
                                        15 |

                                        16 |
                                        17 |
                                          18 |
                                          19 | 20 | -------------------------------------------------------------------------------- /event/resize/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Resize QUnit Test 5 | 6 | 7 | 8 | 9 |

                                          selection Test Suite

                                          10 |

                                          11 |
                                          12 |

                                          13 |
                                          14 |
                                            15 |
                                            16 | 17 | -------------------------------------------------------------------------------- /event/resize/resize.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | selection 6 | 15 | 16 | 17 |

                                            Click an element to see who gets resized as a result. Elements with red borders are 18 | resizable.

                                            19 |
                                              20 |
                                            • Hello World
                                            • 21 |
                                            • Hello World2

                                              22 |
                                                23 |
                                              • Another Item
                                              • 24 |
                                              25 |
                                            • 26 |
                                            • JavaScriptMVC is just WAY smart
                                            • 27 |
                                            28 | 43 | 46 | 47 | -------------------------------------------------------------------------------- /event/resize/resize_test.js: -------------------------------------------------------------------------------- 1 | 2 | steal('funcunit/qunit', 'jquery/event/resize').then(function() { 3 | 4 | module("jquery/event/resize") 5 | 6 | 7 | test("resize hits only children in order", function() { 8 | var ids = [] 9 | record = function( ev ) { 10 | ids.push(this.id ? this.id : this) 11 | }, 12 | divs = $("#qunit-test-area").html("
                                            ").find('div').bind('resize', record); 13 | 14 | $(document.body).bind('resize', record); 15 | 16 | $("#qunit-test-area").children().eq(0).trigger("resize"); 17 | 18 | same(ids, ['1', '1.1', '1.2']) 19 | 20 | ids = []; 21 | $("#qunit-test-area").trigger("resize"); 22 | same(ids, [document.body, '1', '1.1', '1.2', '2']); 23 | 24 | ids = []; 25 | $(window).trigger("resize"); 26 | same(ids, [document.body, '1', '1.1', '1.2', '2']); 27 | 28 | $(document.body).unbind('resize', record); 29 | }); 30 | 31 | test("resize stopping prop", function() { 32 | var ids = [] 33 | record = function( ev ) { 34 | 35 | ids.push(this.id ? this.id : this) 36 | if ( this.id == '1' ) { 37 | ev.stopPropagation(); 38 | } 39 | }, 40 | divs = $("#qunit-test-area").html("
                                            ").find('div').bind('resize', record); 41 | 42 | $(document.body).bind('resize', record); 43 | 44 | $(window).trigger("resize"); 45 | same(ids, [document.body, '1', '2']); 46 | 47 | $(document.body).unbind('resize', record); 48 | }); 49 | 50 | test("resize event cascades from target", function() { 51 | 52 | var ids = [], 53 | record = function( ev ) { 54 | ids.push(this.id ? this.id : this); 55 | }, 56 | 57 | divs = $("#qunit-test-area").html("
                                            "); 58 | 59 | divs.find("#1\\.1\\.1").bind("resize", record); 60 | divs.find("#1").bind("resize", record); 61 | 62 | $("#1\\.1").trigger("resize", [false]); 63 | same(ids, ['1.1.1']); 64 | 65 | $("#qunit-test-area").empty(); 66 | }); 67 | 68 | 69 | }) -------------------------------------------------------------------------------- /event/selection/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | selection QUnit Test 5 | 8 | 9 | 10 | 11 | 12 |

                                            selection Test Suite

                                            13 |

                                            14 |
                                            15 |

                                            16 |
                                            17 |
                                              18 |
                                              19 | 20 | -------------------------------------------------------------------------------- /event/selection/selection_test.js: -------------------------------------------------------------------------------- 1 | steal("funcunit/qunit", "jquery/dom/selection").then(function(){ 2 | 3 | module("jquery/dom/selection"); 4 | 5 | test("getCharElement", function(){ 6 | $("#qunit-test-area") 7 | .html(""+ 8 | ""+ 9 | "

                                              0123456789

                                              "+ 10 | "
                                              012
                                              345
                                              "); 11 | stop(); 12 | setTimeout(function(){ 13 | var types = ['textarea','#inp','#1','#2']; 14 | for(var i =0; i< types.length; i++){ 15 | console.log(types[i]) 16 | $(types[i]).selection(1,5); 17 | } 18 | /* 19 | $('textarea').selection(1,5); 20 | $('input').selection(1,5); 21 | $('#1').selection(1,5); 22 | $('#2').selection(1,5); 23 | */ 24 | var res = []; 25 | for(var i =0; i< types.length; i++){ 26 | res.push( $(types[i]).selection() ); 27 | } 28 | 29 | 30 | 31 | for(var i =0; i< res.length; i++){ 32 | same(res[i],{start: 1, end: 5},types[i]) 33 | } 34 | 35 | start(); 36 | },1000) 37 | }); 38 | 39 | }); -------------------------------------------------------------------------------- /event/swipe/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | swipe QUnit Test 5 | 8 | 9 | 10 | 11 | 12 |

                                              swipe Test Suite

                                              13 |

                                              14 |
                                              15 |

                                              16 |
                                              17 |
                                                18 |
                                                19 | 20 | -------------------------------------------------------------------------------- /event/swipe/swipe.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | swipe 6 | 21 | 22 | 23 |
                                                Swipe Me
                                                24 |
                                                Swipes 25 |
                                                  26 |
                                                • Swipe Me
                                                • 27 |
                                                • Swipe Me
                                                • 28 |
                                                • Swipe Me
                                                • 29 |
                                                • Swipe Me
                                                • 30 |
                                                31 |
                                                32 | 49 | 50 | -------------------------------------------------------------------------------- /event/swipe/swipe_test.js: -------------------------------------------------------------------------------- 1 | steal('funcunit/qunit','funcunit/syn','jquery/event/swipe').then(function(){ 2 | 3 | module("jquery/swipe", {setup : function(){ 4 | $("#qunit-test-area").html("") 5 | var div = $("
                                                "+ 6 | "
                                                one
                                                "+ 7 | "
                                                two
                                                three
                                                "+ 8 | "
                                                "); 9 | 10 | div.appendTo($("#qunit-test-area")); 11 | var basicCss = { 12 | position: "absolute", 13 | border: "solid 1px black" 14 | } 15 | $("#outer").css(basicCss).css({top: "10px", left: "10px", 16 | zIndex: 1000, backgroundColor: "green", width: "200px", height: "200px"}) 17 | }}); 18 | 19 | test("swipe right event",2, function(){ 20 | 21 | $("#outer").bind("swipe",function(){ 22 | ok(true,"swipe called"); 23 | }).bind("swipeleft", function(){ 24 | ok(false, "swipe left") 25 | }).bind("swiperight", function(){ 26 | ok(true, "swiperight") 27 | }); 28 | stop(); 29 | Syn.drag({ 30 | from: "20x20", 31 | to: "50x20", 32 | duration: 100, 33 | },"outer", function(){ 34 | start(); 35 | }) 36 | 37 | }); 38 | 39 | 40 | test("swipe left event",2, function(){ 41 | 42 | $("#outer").bind("swipe",function(){ 43 | ok(true,"swipe called"); 44 | }).bind("swipeleft", function(){ 45 | ok(true, "swipe left") 46 | }).bind("swiperight", function(){ 47 | ok(false, "swiperight") 48 | }); 49 | stop(); 50 | Syn.drag({ 51 | from: "50x20", 52 | to: "20x20", 53 | duration: 100, 54 | },"outer", function(){ 55 | start(); 56 | }) 57 | 58 | }); 59 | 60 | 61 | test("swipe up event",2, function(){ 62 | 63 | $("#outer").bind("swipe",function(){ 64 | ok(true,"swipe called"); 65 | }).bind("swipeup", function(){ 66 | ok(true, "swipe left") 67 | }).bind("swiperight", function(){ 68 | ok(false, "swiperight") 69 | }).bind("swipedown", function(){ 70 | ok(false, "swipedown") 71 | }); 72 | stop(); 73 | Syn.drag({ 74 | from: "20x50", 75 | to: "20x20", 76 | duration: 100, 77 | },"outer", function(){ 78 | start(); 79 | }) 80 | 81 | }); 82 | 83 | test("swipe down event",2, function(){ 84 | 85 | $("#outer").bind("swipe",function(){ 86 | ok(true,"swipe called"); 87 | }).bind("swipeup", function(){ 88 | ok(false, "swipe left") 89 | }).bind("swiperight", function(){ 90 | ok(false, "swiperight") 91 | }).bind("swipedown", function(){ 92 | ok(true, "swipedown") 93 | }); 94 | stop(); 95 | Syn.drag({ 96 | from: "20x20", 97 | to: "20x50", 98 | duration: 100, 99 | },"outer", function(){ 100 | start(); 101 | }) 102 | 103 | }); 104 | 105 | 106 | 107 | 108 | 109 | 110 | }) -------------------------------------------------------------------------------- /event/tap/tap.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | select 6 | 21 | 22 | 23 | I'd Tap That 24 | 27 | 32 | 33 | -------------------------------------------------------------------------------- /event/tap/tap.js: -------------------------------------------------------------------------------- 1 | steal('jquery/event/livehack').then(function($){ 2 | var supportTouch = "ontouchend" in document, 3 | scrollEvent = "touchmove scroll", 4 | touchStartEvent = supportTouch ? "touchstart" : "mousedown", 5 | touchStopEvent = supportTouch ? "touchend" : "mouseup", 6 | touchMoveEvent = supportTouch ? "touchmove" : "mousemove", 7 | data = function(event){ 8 | var d = event.originalEvent.touches ? 9 | event.originalEvent.touches[ 0 ] || event.originalEvent.changedTouches[ 0 ] : 10 | event; 11 | return { 12 | time: (new Date).getTime(), 13 | coords: [ d.pageX, d.pageY ], 14 | origin: $( event.target ) 15 | }; 16 | }; 17 | 18 | /** 19 | * @add jQuery.event.special 20 | */ 21 | $.event.setupHelper( ["tap"], touchStartEvent, function(ev){ 22 | //listen to mouseup 23 | var start = data(ev), 24 | stop, 25 | delegate = ev.delegateTarget || ev.currentTarget, 26 | selector = ev.handleObj.selector, 27 | entered = this, 28 | moved = false, 29 | touching = true, 30 | timer; 31 | 32 | 33 | function upHandler(event){ 34 | stop = data(event); 35 | if ((Math.abs( start.coords[0] - stop.coords[0] ) < 10) && 36 | ( Math.abs( start.coords[1] - stop.coords[1] ) < 10) ){ 37 | $.each($.event.find(delegate, ["tap"], selector), function(){ 38 | this.call(entered, ev, {start : start, end: stop}) 39 | }) 40 | } 41 | }; 42 | 43 | timer = setTimeout(function() { 44 | $(delegate).unbind(touchStopEvent, upHandler); 45 | }, 500 ); 46 | 47 | $(delegate).one(touchStopEvent, upHandler); 48 | 49 | }); 50 | 51 | }); -------------------------------------------------------------------------------- /generate/app: -------------------------------------------------------------------------------- 1 | // _args = ['cookbook']; load('steal/generate/app') 2 | 3 | if (!_args[0]) { 4 | print("Usage: steal/js steal/generate/app path"); 5 | quit(); 6 | } 7 | 8 | load('steal/rhino/rhino.js'); 9 | 10 | steal('steal/generate','steal/generate/system.js',function(steal){ 11 | var classed = steal.generate.toClass(_args[0]), 12 | md = steal.generate.convert(classed), 13 | data = steal.extend({ 14 | path: _args[0], 15 | application_name: md.underscore, 16 | current_path: steal.File.cwdURL(), 17 | path_to_steal : steal.File(_args[0]).pathToRoot() 18 | }, steal.system); 19 | 20 | 21 | steal.generate("jquery/generate/templates/app", _args[0], data); 22 | }); 23 | 24 | -------------------------------------------------------------------------------- /generate/coffee/controller: -------------------------------------------------------------------------------- 1 | if (_args.length < 1) { 2 | print("USAGE : steal/js steal/generate/coffee/controller Company.Widget") 3 | print("EX : steal/js steal/generate/coffee/controller Company.WidgetName"); 4 | print(" > company/widget_name/widget_name.coffee") 5 | print(); 6 | quit(); 7 | } 8 | 9 | load('steal/rhino/rhino.js'); 10 | 11 | steal( '//steal/generate/generate', 12 | '//steal/generate/system', 13 | function(steal){ 14 | var upper = function(parts){ 15 | for(var i =0; i < parts.length; i++){ 16 | parts[i] = parts[i].charAt(0).toUpperCase()+parts[i].substr(1) 17 | } 18 | return parts 19 | } 20 | 21 | if(_args[0].charAt(0) !== _args[0].charAt(0).toUpperCase()){ 22 | var caps = upper( _args[0].split(/_|-/) ).join(''), 23 | name = upper(caps.split("/")).join('.'); 24 | 25 | print(" Creating "+name); 26 | _args[0] = name; 27 | } 28 | 29 | var md = steal.generate.convert(_args[0]), 30 | path = _args[0].toLowerCase().replace('.',"/"); 31 | md.path_to_steal = new steal.File(path).pathToRoot() 32 | steal.generate("jquery/generate/coffee/templates/controller",md.path+"/"+md.underscore,md) 33 | 34 | }); 35 | 36 | -------------------------------------------------------------------------------- /generate/coffee/templates/controller/(underscore).coffee.ejs: -------------------------------------------------------------------------------- 1 | steal "jquery/controller", 2 | ($) -> 3 | 4 | $.Controller "<%= name %>", 5 | { 6 | defaults : {}, 7 | }, 8 | { 9 | init : -> 10 | @element.html "Hello World!" 11 | } 12 | -------------------------------------------------------------------------------- /generate/coffee/templates/controller/(underscore).html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= name %> 5 | 11 | 12 | 13 |

                                                <%= name %> Demo

                                                14 |
                                                15 | 18 | 23 | 24 | -------------------------------------------------------------------------------- /generate/coffee/templates/controller/(underscore)_test.coffee.ejs: -------------------------------------------------------------------------------- 1 | steal "funcunit", 2 | -> 3 | module "<%= fullName %>", setup: -> 4 | S.open "//<%= path %>/<%=underscore%>/<%=underscore%>.html" 5 | 6 | test "Text Test", -> 7 | equals S("h1").text(), "<%= fullName %> Demo", "demo text" -------------------------------------------------------------------------------- /generate/coffee/templates/controller/funcunit.html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= name %> FuncUnit Test 6 | 7 | 8 | 9 | 10 |

                                                <%= name %> Test Suite

                                                11 |

                                                12 |
                                                13 |

                                                14 |
                                                  15 | 16 | -------------------------------------------------------------------------------- /generate/controller: -------------------------------------------------------------------------------- 1 | if (_args.length < 1) { 2 | print("USAGE : steal/js steal/generate/controller Company.Widget") 3 | print("EX : steal/js steal/generate/controller Company.WidgetName"); 4 | print(" > company/widget_name/widget_name.js") 5 | print(); 6 | quit(); 7 | } 8 | 9 | load('steal/rhino/rhino.js'); 10 | 11 | steal( 'steal/generate', 12 | 'steal/generate/system.js', 13 | function(steal){ 14 | var upper = function(parts){ 15 | for(var i =0; i < parts.length; i++){ 16 | parts[i] = parts[i].charAt(0).toUpperCase()+parts[i].substr(1) 17 | } 18 | return parts 19 | } 20 | 21 | if(_args[0].charAt(0) !== _args[0].charAt(0).toUpperCase()){ 22 | var caps = upper( _args[0].split(/_|-/) ).join(''), 23 | name = upper(caps.split("/")).join('.'); 24 | 25 | print(" Creating "+name); 26 | _args[0] = name; 27 | } 28 | 29 | var md = steal.generate.convert(_args[0]), 30 | path = _args[0].toLowerCase().replace(/\./g,"/"); 31 | 32 | md.path_to_steal = new steal.File(path).pathToRoot() 33 | steal.generate("jquery/generate/templates/controller",md.path+"/"+md.underscore,md) 34 | 35 | }); 36 | 37 | -------------------------------------------------------------------------------- /generate/model: -------------------------------------------------------------------------------- 1 | if (_args.length < 1) { 2 | print("USAGE : js jquery/generate/model cookbook/models/recipe") 3 | print(); 4 | quit(); 5 | } 6 | 7 | load('steal/rhino/rhino.js'); 8 | 9 | steal( 'steal/generate', 10 | 'steal/generate/system.js', 11 | 'steal/generate/inflector.js', 12 | function(steal){ 13 | 14 | var upper = function(parts){ 15 | for(var i =0; i < parts.length; i++){ 16 | parts[i] = parts[i].charAt(0).toUpperCase()+parts[i].substr(1) 17 | } 18 | return parts 19 | } 20 | 21 | if(_args[0].charAt(0) !== _args[0].charAt(0).toUpperCase()){ 22 | var caps = upper( _args[0].split(/_|-/) ).join(''), 23 | name = upper(caps.split("/")).join('.'); 24 | 25 | print(" Creating "+name); 26 | _args[0] = name; 27 | } 28 | 29 | var md = steal.generate.convert(_args[0]), 30 | path = _args[0].toLowerCase().replace('.',"/"); 31 | 32 | var folder = md.path.replace(/\/\w+$/, "") 33 | if(!folder){ 34 | print("! Error: Models need to be part of an app"); 35 | quit(); 36 | } 37 | if(!steal.File(folder).exists()){ 38 | print("! Error: folder "+folder+" does not exist!"); 39 | quit(); 40 | } 41 | 42 | md.path_to_steal = new steal.File(path).pathToRoot(); 43 | md.appPath = md.path.replace(/\/models$/,""); 44 | 45 | //check pluralization of last part 46 | if(steal.Inflector.singularize(md.underscore) !== md.underscore){ 47 | print("! Warning: Model names should be singular. I don't think "+md.underscore+" is singular!") 48 | } 49 | 50 | 51 | // generate the files 52 | steal.generate("jquery/generate/templates/model", md.appPath, md) 53 | 54 | try{ 55 | // steal this model in models.js 56 | steal.generate.insertSteal(md.appPath+"/models/models.js", "./"+md.underscore+".js"); 57 | 58 | // steal this model's unit test in qunit.js 59 | steal.generate.insertSteal(md.appPath+"/test/qunit/qunit.js", "./"+md.underscore+"_test.js"); 60 | } catch (e) { 61 | if(e.type && e.type == "DUPLICATE"){ 62 | print("! Error: This model was already created!") 63 | quit(); 64 | } 65 | } 66 | 67 | // $.fixture.make for this model in fixtures.js 68 | var text = readFile("jquery/generate/templates/fixturemake.ejs"); 69 | var fixturetext = new steal.EJS({ 70 | text: text 71 | }).render(md); 72 | steal.generate.insertCode(md.appPath+"/fixtures/fixtures.js", fixturetext); 73 | 74 | }); -------------------------------------------------------------------------------- /generate/page: -------------------------------------------------------------------------------- 1 | if (_args.length < 2) { 2 | print("Creates an html page that loads one of your applications.\n") 3 | print("USAGE: js steal/generate/test app_name page_location\n") 4 | print(); 5 | quit(); 6 | } 7 | 8 | load('steal/rhino/rhino.js'); 9 | 10 | steal('steal/generate','steal/generate/system.js',function(steal){ 11 | var path = _args[0].toLowerCase().replace('.',"/") 12 | var data = steal.extend({ 13 | path: path, 14 | application_name: path.match(/[^\/]*$/)[0], 15 | current_path: steal.File.cwdURL(), 16 | path_to_steal : new steal.File(path).pathToRoot() 17 | }, steal.system) 18 | 19 | var to = path+"/"+_args[1]; 20 | steal.generate.render("jquery/generate/templates/page.ejs", to, data) 21 | }); -------------------------------------------------------------------------------- /generate/plugin: -------------------------------------------------------------------------------- 1 | // _args = ['thing']; load('steal/generate/app') 2 | 3 | if (!_args[0]) { 4 | print("Usage: steal/js steal/generate/plugin path"); 5 | quit(); 6 | } 7 | load('steal/rhino/rhino.js'); 8 | 9 | steal('steal/generate',function(steal){ 10 | var data = steal.extend({ 11 | path: _args[0], 12 | application_name: _args[0].match(/[^\/]*$/)[0], 13 | current_path: steal.File.cwdURL(), 14 | path_to_steal : new steal.File(_args[0]).pathToRoot() 15 | }, steal.system) 16 | 17 | steal.generate("jquery/generate/templates/plugin",_args[0],data) 18 | 19 | })(); 20 | 21 | -------------------------------------------------------------------------------- /generate/scaffold: -------------------------------------------------------------------------------- 1 | if (_args.length < 1) { 2 | print("USAGE : steal/js steal/generate/scaffold FullName Type") 3 | print("TYPES : JsonRest\n") 4 | print("EX : js steal/generate/scaffold Cashnet.Models.Customer"); 5 | print(" > cashnet/models/customer.js ....") 6 | print(); 7 | quit(); 8 | } 9 | 10 | load('steal/rhino/rhino.js'); 11 | 12 | steal( 'steal/generate', 13 | 'steal/generate/system.js', 14 | 'jquery/generate/templates/model.js', 15 | function(steal){ 16 | //check capitalization 17 | 18 | steal.generate.model(_args[0]); 19 | 20 | var parts = _args[0].split("."), part; 21 | 22 | for(var i=0; i< parts.length;i++){ 23 | part = parts[i]; 24 | if( part[0] !== part[0].toUpperCase() ){ 25 | print("! Warning: "+part+" should probably be capitalized. JavaScriptMVC likes capital namespaces and class names.") 26 | } 27 | parts[i] = steal.generate.underscore(part); 28 | } 29 | // check folders 30 | var folder = parts.slice(0, parts.length-1).join("/"); 31 | if(!folder){ 32 | print("! Error: Scaffolding needs to be part of an app"); 33 | quit(); 34 | } 35 | if(!steal.File(folder).exists()){ 36 | print("! Error: folder "+folder+" does not exist!"); 37 | quit(); 38 | } 39 | //check pluralization of last part 40 | if(steal.Inflector.singularize(part) !== part){ 41 | print("! Warning: Model names should be singular. I don't think "+part+ 42 | " is singular!") 43 | } 44 | 45 | var md = steal.generate.convert(_args[0]); 46 | 47 | md.type = _args[1] 48 | 49 | md.appPath = md.path.replace(/\/models$/,""); 50 | md.baseName = md.name.replace(/\.Models.*/, "."+md.className); 51 | steal.generate("jquery/generate/templates/scaffold",md.appPath+"/"+md.underscore,md); 52 | 53 | steal.generate.insertSteal( 54 | md.appPath+"/test/funcunit/funcunit.js", 55 | md.appPath+"/"+md.underscore+"/create/create_test.js"); 56 | 57 | steal.generate.insertSteal( 58 | md.appPath+"/test/funcunit/funcunit.js", 59 | md.appPath+"/"+md.underscore+"/list/list_test.js") 60 | 61 | steal.generate.insertSteal( 62 | md.appPath+"/"+md.appPath+".js", 63 | md.appPath+"/"+md.underscore+"/create", true) 64 | steal.generate.insertSteal( 65 | md.appPath+"/"+md.appPath+".js", 66 | md.appPath+"/"+md.underscore+"/list", true) 67 | 68 | 69 | var text = readFile("jquery/generate/templates/scaffoldHookup.ejs"); 70 | var hookup = new steal.EJS({ 71 | text: text 72 | }).render(md); 73 | steal.generate.insertCode(md.appPath+"/"+md.appPath+".js", hookup ); 74 | }); -------------------------------------------------------------------------------- /generate/templates/app/(application_name).css.ejs: -------------------------------------------------------------------------------- 1 | body { 2 | font-family:Lucida Sans,Lucida Grande,Arial,sans-serif; 3 | margin:0; 4 | line-height:22px; 5 | width:960px; 6 | margin:0 auto; 7 | } 8 | h1 { 9 | padding:30px 0 10px; 10 | margin-top:0; 11 | line-height:30px; 12 | } 13 | 14 | ul{ 15 | padding:0 0 0 15px; 16 | list-style : none; 17 | } 18 | 19 | a { 20 | color:#ae3d26; 21 | text-decoration:none; 22 | } 23 | 24 | a:hover { text-decoration:underline; } 25 | 26 | hr { 27 | border:none; 28 | border-top:1px dotted #000; 29 | } -------------------------------------------------------------------------------- /generate/templates/app/(application_name).html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= application_name %> 5 | 6 | 7 |

                                                  Welcome to JavaScriptMVC 3.2!

                                                  8 |
                                                    9 |
                                                  • Steal plugins and files in <%= path %>/<%= application_name %>.js.
                                                  • 10 |
                                                  • Change to production mode by changing steal.js to steal.production.js in this file.
                                                  • 11 |
                                                  12 |
                                                  13 | Here are some links to get you started: 14 | 20 |
                                                  21 | Join the community: 22 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /generate/templates/app/(application_name).js.ejs: -------------------------------------------------------------------------------- 1 | steal( 2 | './<%= application_name %>.css', // application CSS file 3 | './models/models.js', // steals all your models 4 | './fixtures/fixtures.js', // sets up fixtures for your models 5 | function(){ // configure your application 6 | 7 | }) -------------------------------------------------------------------------------- /generate/templates/app/(application_name).md.ejs: -------------------------------------------------------------------------------- 1 | @page index <%= application_name %> 2 | 3 | This is a placeholder for the homepage of your documentation. -------------------------------------------------------------------------------- /generate/templates/app/docs/.ignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiterjs/jquerymx/0f917a85327a6c0196c2cf28c1d90a9095e0eae1/generate/templates/app/docs/.ignore -------------------------------------------------------------------------------- /generate/templates/app/fixtures/.ignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiterjs/jquerymx/0f917a85327a6c0196c2cf28c1d90a9095e0eae1/generate/templates/app/fixtures/.ignore -------------------------------------------------------------------------------- /generate/templates/app/fixtures/fixtures.js.ejs: -------------------------------------------------------------------------------- 1 | // map fixtures for this application 2 | 3 | steal("jquery/dom/fixture", function(){ 4 | 5 | }) -------------------------------------------------------------------------------- /generate/templates/app/funcunit.html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= application_name%> FuncUnit Test 6 | 7 | 8 | 9 |

                                                  <%= application_name%> Test Suite

                                                  10 |

                                                  11 |
                                                  12 |

                                                  13 |
                                                    14 | 15 | -------------------------------------------------------------------------------- /generate/templates/app/models/.ignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiterjs/jquerymx/0f917a85327a6c0196c2cf28c1d90a9095e0eae1/generate/templates/app/models/.ignore -------------------------------------------------------------------------------- /generate/templates/app/models/models.js.ejs: -------------------------------------------------------------------------------- 1 | // steal model files 2 | steal("jquery/model") -------------------------------------------------------------------------------- /generate/templates/app/qunit.html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= application_name%> QUnit Test 6 | 9 | 10 | 11 | 12 | 13 |

                                                    <%= application_name%> Test Suite

                                                    14 |

                                                    15 |
                                                    16 |

                                                    17 |
                                                    18 |
                                                      19 |
                                                      20 | 21 | -------------------------------------------------------------------------------- /generate/templates/app/scripts/build.html.ejs: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | <%= application_name %> Build Page 6 | 7 | 8 |

                                                      <%= application_name %> Build Page

                                                      9 |

                                                      This is a dummy page that loads your app so steal can 10 | get all the files. 11 |

                                                      12 |

                                                      If you built your app 13 | to depend on HTML in the page before DOMContent loaded or 14 | onload, you can add the HTML here, or you can change the 15 | build.js script to point to a better html file. 16 |

                                                      17 | 20 | 21 | -------------------------------------------------------------------------------- /generate/templates/app/scripts/build.js.ejs: -------------------------------------------------------------------------------- 1 | //js <%= path %>/scripts/build.js 2 | 3 | load("steal/rhino/rhino.js"); 4 | steal('steal/build').then('steal/build/scripts','steal/build/styles',function(){ 5 | steal.build('<%= path %>/scripts/build.html',{to: '<%= path %>'}); 6 | }); 7 | -------------------------------------------------------------------------------- /generate/templates/app/scripts/clean.js.ejs: -------------------------------------------------------------------------------- 1 | //steal/js <%= path %>/scripts/compress.js 2 | 3 | load("steal/rhino/rhino.js"); 4 | steal('steal/clean',function(){ 5 | steal.clean('<%= path %>/<%= application_name %>.html',{ 6 | indent_size: 1, 7 | indent_char: '\t', 8 | jslint : false, 9 | ignore: /jquery\/jquery.js/, 10 | predefined: { 11 | steal: true, 12 | jQuery: true, 13 | $ : true, 14 | window : true 15 | } 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /generate/templates/app/scripts/crawl.js.ejs: -------------------------------------------------------------------------------- 1 | // load('<%= path %>/scripts/crawl.js') 2 | 3 | load('steal/rhino/rhino.js') 4 | 5 | steal('steal/html/crawl', function(){ 6 | steal.html.crawl("<%= path %>/<%= application_name %>.html","<%= path %>/out") 7 | }); 8 | -------------------------------------------------------------------------------- /generate/templates/app/scripts/docs.js.ejs: -------------------------------------------------------------------------------- 1 | //js <%= path %>/scripts/doc.js 2 | 3 | load('steal/rhino/rhino.js'); 4 | steal("documentjs").then(function(){ 5 | DocumentJS('<%= path %>/<%= application_name %>.html', { 6 | markdown : ['<%= application_name %>'] 7 | }); 8 | }); -------------------------------------------------------------------------------- /generate/templates/app/test/funcunit/(application_name)_test.js.ejs: -------------------------------------------------------------------------------- 1 | steal("funcunit", function(){ 2 | module("<%=application_name%> test", { 3 | setup: function(){ 4 | S.open("//<%= path %>/<%=application_name%>.html"); 5 | } 6 | }); 7 | 8 | test("Copy Test", function(){ 9 | equals(S("h1").text(), "Welcome to JavaScriptMVC 3.2!","welcome text"); 10 | }); 11 | }) -------------------------------------------------------------------------------- /generate/templates/app/test/funcunit/funcunit.js.ejs: -------------------------------------------------------------------------------- 1 | steal("funcunit") 2 | .then("./<%= application_name %>_test.js"); -------------------------------------------------------------------------------- /generate/templates/app/test/qunit/(application_name)_test.js.ejs: -------------------------------------------------------------------------------- 1 | steal("funcunit/qunit", function(){ 2 | module("<%= application_name %>"); 3 | 4 | test("<%= application_name %> testing works", function(){ 5 | ok(true,"an assert is run"); 6 | }); 7 | }) -------------------------------------------------------------------------------- /generate/templates/app/test/qunit/qunit.js.ejs: -------------------------------------------------------------------------------- 1 | steal("funcunit/qunit", "./<%= application_name %>_test.js"); -------------------------------------------------------------------------------- /generate/templates/controller/(underscore).html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= name %> 5 | 11 | 12 | 13 |

                                                      <%= name %> Demo

                                                      14 |
                                                      15 | 18 | 24 | 25 | -------------------------------------------------------------------------------- /generate/templates/controller/(underscore).js.ejs: -------------------------------------------------------------------------------- 1 | steal( 'jquery/controller','jquery/view/ejs' ) 2 | .then( './views/init.ejs', function($){ 3 | 4 | /** 5 | * @class <%= name %> 6 | */ 7 | $.Controller('<%= name %>', 8 | /** @Static */ 9 | { 10 | defaults : {} 11 | }, 12 | /** @Prototype */ 13 | { 14 | init : function(){ 15 | this.element.html("//<%= path %>/<%= underscore %>/views/init.ejs",{ 16 | message: "Hello World" 17 | }); 18 | } 19 | }) 20 | 21 | }); -------------------------------------------------------------------------------- /generate/templates/controller/(underscore)_test.js.ejs: -------------------------------------------------------------------------------- 1 | steal('funcunit').then(function(){ 2 | 3 | module("<%= fullName %>", { 4 | setup: function(){ 5 | S.open("//<%= path %>/<%=underscore%>/<%=underscore%>.html"); 6 | } 7 | }); 8 | 9 | test("Text Test", function(){ 10 | equals(S("h1").text(), "<%= fullName %> Demo","demo text"); 11 | }); 12 | 13 | 14 | }); -------------------------------------------------------------------------------- /generate/templates/controller/funcunit.html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= name %> FuncUnit Test 6 | 7 | 8 | 9 | 10 |

                                                      <%= name %> Test Suite

                                                      11 |

                                                      12 |
                                                      13 |

                                                      14 |
                                                        15 | 16 | -------------------------------------------------------------------------------- /generate/templates/controller/views/.ignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiterjs/jquerymx/0f917a85327a6c0196c2cf28c1d90a9095e0eae1/generate/templates/controller/views/.ignore -------------------------------------------------------------------------------- /generate/templates/controller/views/init.ejs.ejs: -------------------------------------------------------------------------------- 1 | <%%= this.message %> -------------------------------------------------------------------------------- /generate/templates/fixturemake.ejs: -------------------------------------------------------------------------------- 1 | $.fixture.make("<%= underscore %>", 5, function(i, <%= underscore %>){ 2 | var descriptions = ["grill fish", "make ice", "cut onions"] 3 | return { 4 | name: "<%= underscore %> "+i, 5 | description: $.fixture.rand( descriptions , 1)[0] 6 | } 7 | }) -------------------------------------------------------------------------------- /generate/templates/model.js: -------------------------------------------------------------------------------- 1 | steal( 'steal/generate', 2 | 'steal/generate/system.js', 3 | 'steal/generate/inflector.js', 4 | function(steal){ 5 | 6 | 7 | 8 | var upper = function(parts){ 9 | for(var i =0; i < parts.length; i++){ 10 | parts[i] = parts[i].charAt(0).toUpperCase()+parts[i].substr(1) 11 | } 12 | return parts 13 | } 14 | 15 | steal.generate.model = function(arg){ 16 | 17 | if(arg.charAt(0) !== arg.charAt(0).toUpperCase()){ 18 | var caps = upper( arg.split(/_|-/) ).join(''), 19 | name = upper(caps.split("/")).join('.'); 20 | 21 | print(" Creating "+name); 22 | arg = name; 23 | } 24 | 25 | var md = steal.generate.convert(arg), 26 | path = arg.toLowerCase().replace('.',"/"); 27 | 28 | var folder = md.path.replace(/\/\w+$/, "") 29 | if(!folder){ 30 | print("! Error: Models need to be part of an app"); 31 | quit(); 32 | } 33 | if(!steal.File(folder).exists()){ 34 | print("! Error: folder "+folder+" does not exist!"); 35 | quit(); 36 | } 37 | 38 | md.path_to_steal = new steal.File(path).pathToRoot(); 39 | md.appPath = md.path.replace(/\/models$/,""); 40 | 41 | //check pluralization of last part 42 | if(steal.Inflector.singularize(md.underscore) !== md.underscore){ 43 | print("! Warning: Model names should be singular. I don't think "+md.underscore+" is singular!") 44 | } 45 | 46 | // generate the files 47 | steal.generate("jquery/generate/templates/model", md.appPath, md) 48 | 49 | try{ 50 | // steal this model in models.js 51 | steal.generate.insertSteal(md.appPath+"/models/models.js", "./"+md.underscore+".js"); 52 | 53 | // steal this model's unit test in qunit.js 54 | steal.generate.insertSteal(md.appPath+"/test/qunit/qunit.js", "./"+md.underscore+"_test.js"); 55 | } catch (e) { 56 | if(e.type && e.type == "DUPLICATE"){ 57 | print("! Error: This model was already created!") 58 | quit(); 59 | } 60 | } 61 | // $.fixture.make for this model in fixtures.js 62 | 63 | 64 | 65 | var text = readFile("jquery/generate/templates/fixturemake.ejs"); 66 | var fixturetext = new steal.EJS({ 67 | text: text 68 | }).render(md); 69 | steal.generate.insertCode(md.appPath+"/fixtures/fixtures.js", fixturetext); 70 | 71 | } 72 | 73 | 74 | 75 | }); -------------------------------------------------------------------------------- /generate/templates/model/models/(underscore).js.ejs: -------------------------------------------------------------------------------- 1 | steal('jquery/model', function(){ 2 | 3 | /** 4 | * @class <%=name%> 5 | * @parent index 6 | * @inherits jQuery.Model 7 | * Wraps backend <%=underscore%> services. 8 | */ 9 | $.Model('<%=name%>', 10 | /* @Static */ 11 | { 12 | findAll: "/<%= plural %>.json", 13 | findOne : "/<%= plural %>/{id}.json", 14 | create : "/<%= plural %>.json", 15 | update : "/<%= plural %>/{id}.json", 16 | destroy : "/<%= plural %>/{id}.json" 17 | }, 18 | /* @Prototype */ 19 | {}); 20 | 21 | }) -------------------------------------------------------------------------------- /generate/templates/model/test/qunit/(underscore)_test.js.ejs: -------------------------------------------------------------------------------- 1 | steal("funcunit/qunit", "<%= appPath %>/fixtures", "<%= appPath %>/models/<%= underscore %>.js", function(){ 2 | module("Model: <%= name %>") 3 | 4 | test("findAll", function(){ 5 | expect(4); 6 | stop(); 7 | <%= name %>.findAll({}, function(<%= plural %>){ 8 | ok(<%= plural %>) 9 | ok(<%= plural %>.length) 10 | ok(<%= plural %>[0].name) 11 | ok(<%= plural %>[0].description) 12 | start(); 13 | }); 14 | 15 | }) 16 | 17 | test("create", function(){ 18 | expect(3) 19 | stop(); 20 | new <%= name %>({name: "dry cleaning", description: "take to street corner"}).save(function(<%= underscore %>){ 21 | ok(<%= underscore %>); 22 | ok(<%= underscore %>.id); 23 | equals(<%= underscore %>.name,"dry cleaning") 24 | <%= underscore %>.destroy() 25 | start(); 26 | }) 27 | }) 28 | test("update" , function(){ 29 | expect(2); 30 | stop(); 31 | new <%= name %>({name: "cook dinner", description: "chicken"}). 32 | save(function(<%= underscore %>){ 33 | equals(<%= underscore %>.description,"chicken"); 34 | <%= underscore %>.update({description: "steak"},function(<%= underscore %>){ 35 | equals(<%= underscore %>.description,"steak"); 36 | <%= underscore %>.destroy(); 37 | start(); 38 | }) 39 | }) 40 | 41 | }); 42 | test("destroy", function(){ 43 | expect(1); 44 | stop(); 45 | new <%= name %>({name: "mow grass", description: "use riding mower"}). 46 | destroy(function(<%= underscore %>){ 47 | ok( true ,"Destroy called" ) 48 | start(); 49 | }) 50 | }) 51 | }) -------------------------------------------------------------------------------- /generate/templates/page.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= application_name %> 5 | 11 | 12 | 13 |

                                                        Welcome to JavaScriptMVC 3.2!

                                                        14 |
                                                          15 |
                                                        • Steal plugins and files in <%= path %>/<%= application_name %>.js.
                                                        • 16 |
                                                        • Change to production mode by changing steal.js to steal.production.js in this file.
                                                        • 17 |
                                                        18 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /generate/templates/plugin/(application_name).html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= application_name %> 5 | 11 | 12 | 13 |

                                                        <%= application_name %> Demo

                                                        14 |

                                                        This is a dummy page to show off your plugin

                                                        15 | 18 | 23 | 24 | -------------------------------------------------------------------------------- /generate/templates/plugin/(application_name).js.ejs: -------------------------------------------------------------------------------- 1 | steal('jquery',function($){ 2 | 3 | }); -------------------------------------------------------------------------------- /generate/templates/plugin/(application_name)_test.js.ejs: -------------------------------------------------------------------------------- 1 | steal('funcunit/qunit','./<%= application_name %>',function(){ 2 | 3 | module("<%= application_name %>"); 4 | 5 | test("<%= application_name %> testing works", function(){ 6 | ok(true,"an assert is run"); 7 | }); 8 | 9 | 10 | }); -------------------------------------------------------------------------------- /generate/templates/plugin/qunit.html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= application_name%> QUnit Test 6 | 7 | 8 | 9 | 10 |

                                                        <%= application_name%> Test Suite

                                                        11 |

                                                        12 |
                                                        13 |

                                                        14 |
                                                        15 |
                                                          16 |
                                                          17 | 18 | -------------------------------------------------------------------------------- /generate/templates/scaffold/create/create.html.ejs: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | <%=baseName %>.Create 6 | 9 | 10 | 11 |

                                                          <%=baseName %>.Create Demo

                                                          12 |
                                                          13 |
                                                          14 | 17 | 28 | 29 | -------------------------------------------------------------------------------- /generate/templates/scaffold/create/create.js.ejs: -------------------------------------------------------------------------------- 1 | steal( 'jquery/controller', 2 | 'jquery/view/ejs', 3 | 'jquery/dom/form_params', 4 | 'jquery/controller/view', 5 | '<%= appPath %>/models' ) 6 | .then('./views/init.ejs', function($){ 7 | 8 | /** 9 | * @class <%=baseName%>.Create 10 | * @parent index 11 | * @inherits jQuery.Controller 12 | * Creates <%= plural %> 13 | */ 14 | $.Controller('<%=baseName%>.Create', 15 | /** @Prototype */ 16 | { 17 | init : function(){ 18 | this.element.html(this.view()); 19 | }, 20 | submit : function(el, ev){ 21 | ev.preventDefault(); 22 | this.element.find('[type=submit]').val('Creating...') 23 | new <%= name %>(el.formParams()).save(this.callback('saved')); 24 | }, 25 | saved : function(){ 26 | this.element.find('[type=submit]').val('Create'); 27 | this.element[0].reset() 28 | } 29 | }) 30 | 31 | }); -------------------------------------------------------------------------------- /generate/templates/scaffold/create/create_test.js.ejs: -------------------------------------------------------------------------------- 1 | steal('funcunit',function(){ 2 | 3 | module("<%=baseName%>.Create", { 4 | setup: function(){ 5 | S.open("//<%= appPath %>/<%= underscore %>/create/create.html"); 6 | } 7 | }); 8 | 9 | test("create <%= plural %>", function(){ 10 | S("[name=name]").type("Ice Water"); 11 | S("[name=description]").type("Pour water in a glass. Add ice cubes."); 12 | S("[type=submit]").click(); 13 | S('h3:contains(Ice Water)') 14 | .exists(function(){ 15 | ok(true, "Ice Water added"); 16 | equals(S("[name=name]").val() , "", "form reset"); 17 | equals(S("[name=description]").val() , "", "form reset"); 18 | }) 19 | }); 20 | 21 | 22 | }); -------------------------------------------------------------------------------- /generate/templates/scaffold/create/funcunit.html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%=baseName%>.Create FuncUnit Test 5 | 6 | 7 | 8 | 9 |

                                                          <%=baseName%>.Create Test Suite

                                                          10 |

                                                          11 |
                                                          12 |

                                                          13 |
                                                            14 | 15 | -------------------------------------------------------------------------------- /generate/templates/scaffold/create/views/init.ejs.ejs: -------------------------------------------------------------------------------- 1 |

                                                            New <%= underscore %>

                                                            2 |

                                                            3 |
                                                            4 | 5 |

                                                            6 |


                                                            7 | 8 |

                                                            9 |

                                                            -------------------------------------------------------------------------------- /generate/templates/scaffold/list/funcunit.html.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= baseName %>.List Test 5 | 6 | 7 | 8 | 9 |

                                                            <%= baseName %>.List Test

                                                            10 |

                                                            11 |
                                                            12 |

                                                            13 |
                                                              14 | 15 | -------------------------------------------------------------------------------- /generate/templates/scaffold/list/list.html.ejs: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | <%= baseName %>.List Demo 6 | 9 | 10 | 11 |

                                                              <%= baseName %>.List Demo

                                                              12 |
                                                                13 | Create <%= className %> 14 | 17 | 30 | 31 | -------------------------------------------------------------------------------- /generate/templates/scaffold/list/list.js.ejs: -------------------------------------------------------------------------------- 1 | steal( 'jquery/controller', 2 | 'jquery/view/ejs', 3 | 'jquery/controller/view', 4 | '<%= appPath %>/models' ) 5 | .then( './views/init.ejs', 6 | './views/<%= underscore %>.ejs', 7 | function($){ 8 | 9 | /** 10 | * @class <%=baseName%>.List 11 | * @parent index 12 | * @inherits jQuery.Controller 13 | * Lists <%= plural %> and lets you destroy them. 14 | */ 15 | $.Controller('<%=baseName%>.List', 16 | /** @Static */ 17 | { 18 | defaults : {} 19 | }, 20 | /** @Prototype */ 21 | { 22 | init : function(){ 23 | this.element.html(this.view('init',<%= name %>.findAll()) ) 24 | }, 25 | '.destroy click': function( el ){ 26 | if(confirm("Are you sure you want to destroy?")){ 27 | el.closest('.<%= underscore %>').model().destroy(); 28 | } 29 | }, 30 | "{<%= name %>} destroyed" : function(<%= className %>, ev, <%= underscore %>) { 31 | <%= underscore %>.elements(this.element).remove(); 32 | }, 33 | "{<%= name %>} created" : function(<%= className %>, ev, <%= underscore %>){ 34 | this.element.append(this.view('init', [<%= underscore %>])) 35 | }, 36 | "{<%= name %>} updated" : function(<%= className %>, ev, <%= underscore %>){ 37 | <%= underscore %>.elements(this.element) 38 | .html(this.view('<%= underscore %>', <%= underscore %>) ); 39 | } 40 | }); 41 | 42 | }); -------------------------------------------------------------------------------- /generate/templates/scaffold/list/list_test.js.ejs: -------------------------------------------------------------------------------- 1 | steal('funcunit',function(){ 2 | 3 | module("<%=baseName%>.List", { 4 | setup: function(){ 5 | S.open("//<%= appPath %>/<%= underscore %>/list/list.html"); 6 | } 7 | }); 8 | 9 | test("delete <%= plural %>", function(){ 10 | S('#create').click() 11 | 12 | // wait until grilled cheese has been added 13 | S('h3:contains(Grilled Cheese X)').exists(); 14 | 15 | S.confirm(true); 16 | S('h3:last a').click(); 17 | 18 | 19 | S('h3:contains(Grilled Cheese)').missing(function(){ 20 | ok(true,"Grilled Cheese Removed") 21 | }); 22 | 23 | }); 24 | 25 | 26 | }); -------------------------------------------------------------------------------- /generate/templates/scaffold/list/views/(underscore).ejs.ejs: -------------------------------------------------------------------------------- 1 |

                                                                <%%= name %> X

                                                                2 |

                                                                <%%= description %>

                                                                -------------------------------------------------------------------------------- /generate/templates/scaffold/list/views/init.ejs.ejs: -------------------------------------------------------------------------------- 1 | <%%for(var i = 0; i < this.length ; i++){%> 2 |
                                                              • > 3 | <%%== $.View('//<%= appPath %>/<%= underscore %>/list/views/<%= underscore %>.ejs', this[i] )%> 4 |
                                                              • 5 | <%%}%> -------------------------------------------------------------------------------- /generate/templates/scaffoldHookup.ejs: -------------------------------------------------------------------------------- 1 | $('#<%= plural %>').<%=appPath%>_<%= underscore %>_list(); 2 | $('#create').<%=appPath%>_<%= underscore %>_create(); -------------------------------------------------------------------------------- /generate/test/app_plugin_model_controller.js: -------------------------------------------------------------------------------- 1 | load('steal/rhino/rhino.js') 2 | load('steal/rhino/test.js'); 3 | 4 | (function(rhinoSteal){ 5 | _S = steal.test; 6 | 7 | 8 | _S.module("jquery/generate") 9 | STEALPRINT = false; 10 | 11 | _S.test("app" , function(t){ 12 | _args = ['cnu']; 13 | load('jquery/generate/app'); 14 | _S.clear(); 15 | _S.open('cnu/cnu.html') 16 | t.ok(typeof steal !== 'undefined', "steal is fine") 17 | _S.clear(); 18 | }) 19 | 20 | _S.test("app 2 levels deep" , function(t){ 21 | _args = ['cnu/widget']; 22 | load('jquery/generate/plugin'); 23 | _S.clear(); 24 | _S.open('cnu/widget/widget.html') 25 | t.ok(typeof steal !== 'undefined', "steal is fine") 26 | _S.clear(); 27 | }) 28 | 29 | /** 30 | * Tests generating a very basic controller and model 31 | */ 32 | 33 | _S.test("controller, model, and page" , function(t){ 34 | _args = ['Cnu.Todos']; 35 | load('jquery/generate/controller'); 36 | _S.clear(); 37 | 38 | _args = ['Cnu.Models.Todo']; 39 | load('jquery/generate/model'); 40 | _S.clear(); 41 | cnuContent = readFile('cnu/cnu.js') 42 | +"\n.then('./models/todo.js')" 43 | +"\n.then('./todos/todos.js')"; 44 | load('steal/rhino/rhino.js') 45 | new steal.File('cnu/cnu.js').save( cnuContent ); 46 | 47 | 48 | _args = ['cnu','cnugen.html']; 49 | load('jquery/generate/page'); 50 | _S.clear(); 51 | 52 | _S.open('cnu/cnugen.html'); 53 | 54 | t.ok(typeof Cnu.Todos !== 'undefined',"load Cnu.Controllers.Todos") 55 | t.ok(typeof Cnu.Models.Todo !== 'undefined', "load Cnu.Models.Todo") 56 | 57 | rhinoSteal.File("cnu").removeDir(); 58 | }) 59 | 60 | })(steal); 61 | -------------------------------------------------------------------------------- /generate/test/run.js: -------------------------------------------------------------------------------- 1 | load("jquery/generate/test/app_plugin_model_controller.js"); 2 | 3 | load("jquery/generate/test/scaffold.js"); 4 | -------------------------------------------------------------------------------- /generate/test/scaffold.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | load('steal/rhino/rhino.js'); 4 | load('steal/test/test.js'); 5 | 6 | steal('steal/test', function(s){ 7 | 8 | s.test.module("jquery/generate/scaffold") 9 | 10 | STEALPRINT = false; 11 | 12 | s.test.test("make app and scaffold", function(t){ 13 | _args = ['cookbook']; 14 | load('jquery/generate/app'); 15 | _args = ['Cookbook.Models.Recipe']; 16 | load('jquery/generate/scaffold'); 17 | 18 | 19 | load('steal/rhino/rhino.js'); 20 | var cookbookContent = readFile('cookbook/cookbook.js') 21 | +"\n.then('./models/recipe.js')" 22 | +"\n.then('./controllers/recipe_controller.js')"; 23 | new steal.File('cookbook/cookbook.js').save( cookbookContent ); 24 | 25 | var qunitContent = readFile('cookbook/test/qunit/qunit.js'). 26 | replace("cookbook_test", "recipe_test"); 27 | new steal.File('cookbook/test/qunit/qunit.js').save( qunitContent ); 28 | 29 | var funcunitContent = readFile('cookbook/test/funcunit/funcunit.js'). 30 | replace("cookbook_test", "recipe_controller_test"); 31 | new steal.File('cookbook/test/funcunit/funcunit.js').save( funcunitContent ); 32 | 33 | t.clear(); 34 | print('trying to open ...') 35 | t.open('cookbook/cookbook.html', false) 36 | t.ok(Cookbook.Controllers.Recipe, "Recipe Controller") 37 | t.ok(Cookbook.Models.Recipe, "Recipe Controller") 38 | t.clear(); 39 | }); 40 | 41 | //now see if unit and functional run 42 | 43 | // s.test.test("scaffold unit tests", function(t){ 44 | // 45 | // load('steal/rhino/rhino.js'); 46 | // load('funcunit/loader.js'); 47 | // FuncUnit.load('cookbook/qunit.html'); 48 | // }); 49 | // 50 | // s.test.test("scaffold functional tests", function(t){ 51 | // load('steal/rhino/rhino.js'); 52 | // load('funcunit/loader.js'); 53 | // FuncUnit.load('cookbook/funcunit.html'); 54 | // 55 | // }); 56 | // 57 | // s.test.test("documentjs", function(t){ 58 | // t.clear(); 59 | // load('steal/rhino/rhino.js'); 60 | // _args = ['cookbook/cookbook.html'] 61 | // load("documentjs/documentjs.js"); 62 | // DocumentJS('cookbook/cookbook.html'); 63 | // }); 64 | 65 | s.test.test("compress", function(t){ 66 | t.clear(); 67 | load("cookbook/scripts/build.js") 68 | 69 | var cookbookPage = readFile('cookbook/cookbook.html'). 70 | replace("steal.js?cookbook,development", "steal.js?cookbook,production"); 71 | new steal.File('cookbook/cookbook.html').save( cookbookPage ); 72 | 73 | t.clear(); 74 | t.open('cookbook/cookbook.html', false) 75 | t.ok(Cookbook.Controllers.Recipe, "Recipe Controller") 76 | t.ok(Cookbook.Models.Recipe, "Recipe Controller") 77 | t.clear(); 78 | }); 79 | 80 | 81 | //print("-- cleanup --"); 82 | // s.File("cookbook").removeDir(); 83 | 84 | }) 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /lang/lang_test.js: -------------------------------------------------------------------------------- 1 | steal('./object/object_test','./observe/observe_test','./string/string_test') 2 | -------------------------------------------------------------------------------- /lang/object/object.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | object 6 | 12 | 13 | 14 |

                                                                object Demo

                                                                15 |

                                                                This is a dummy page to show off your plugin

                                                                16 | 19 | 24 | 25 | -------------------------------------------------------------------------------- /lang/object/object_test.js: -------------------------------------------------------------------------------- 1 | steal('funcunit/qunit','./object',function(){ 2 | 3 | module("object"); 4 | 5 | test("same", function(){ 6 | 7 | 8 | ok( $.Object.same({type: "FOLDER"},{type: "FOLDER", count: 5}, { 9 | count: null 10 | }), "count ignored" ); 11 | 12 | ok( $.Object.same({type: "folder"},{type: "FOLDER"}, { 13 | type: "i" 14 | }), "folder case ignored" ); 15 | }) 16 | 17 | test("subsets", function(){ 18 | 19 | var res1 = $.Object.subsets({parentId: 5, type: "files"}, 20 | [{parentId: 6}, {type: "folders"}, {type: "files"}]); 21 | 22 | same(res1,[{type: "files"}]) 23 | 24 | var res2 = $.Object.subsets({parentId: 5, type: "files"}, 25 | [{}, {type: "folders"}, {type: "files"}]); 26 | 27 | same(res2,[{},{type: "files"}]); 28 | 29 | var res3 = $.Object.subsets({parentId: 5, type: "folders"}, 30 | [{parentId: 5},{type: "files"}]); 31 | 32 | same(res3,[{parentId: 5}]) 33 | }); 34 | 35 | test("subset compare", function(){ 36 | 37 | ok( $.Object.subset( 38 | {type: "FOLDER"}, 39 | {type: "FOLDER"}), 40 | 41 | "equal sets" ); 42 | 43 | ok( $.Object.subset( 44 | {type: "FOLDER", parentId: 5}, 45 | {type: "FOLDER"}), 46 | 47 | "sub set" ); 48 | 49 | ok(! $.Object.subset( 50 | {type: "FOLDER"}, 51 | {type: "FOLDER", parentId: 5}), 52 | 53 | "wrong way" ); 54 | 55 | 56 | ok(! $.Object.subset( 57 | {type: "FOLDER", parentId: 7}, 58 | {type: "FOLDER", parentId: 5}), 59 | 60 | "different values" ); 61 | 62 | ok( $.Object.subset( 63 | {type: "FOLDER", count: 5}, // subset 64 | {type: "FOLDER"}, 65 | {count: null} ), 66 | 67 | "count ignored" ); 68 | 69 | 70 | ok( $.Object.subset( 71 | {type: "FOLDER", kind: "tree"}, // subset 72 | {type: "FOLDER", foo: true, bar: true }, 73 | {foo: null, bar: null} ), 74 | 75 | "understands a subset" ); 76 | ok( $.Object.subset( 77 | {type: "FOLDER", foo: true, bar: true }, 78 | {type: "FOLDER", kind: "tree"}, // subset 79 | 80 | {foo: null, bar: null, kind : null} ), 81 | 82 | "ignores nulls" ); 83 | }); 84 | 85 | test("searchText", function(){ 86 | var item = { 87 | id: 1, 88 | name: "thinger" 89 | }, 90 | searchText = { 91 | searchText : "foo" 92 | }, 93 | compare = { 94 | searchText : function(items, paramsText, itemr, params){ 95 | equals(item,itemr); 96 | equals(searchText, params) 97 | return true; 98 | } 99 | }; 100 | 101 | ok( $.Object.subset( item, searchText, compare ), "searchText" ); 102 | }); 103 | 104 | 105 | }); -------------------------------------------------------------------------------- /lang/object/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | object QUnit Test 5 | 6 | 7 | 8 | 9 |

                                                                object Test Suite

                                                                10 |

                                                                11 |
                                                                12 |

                                                                13 |
                                                                14 |
                                                                  15 |
                                                                  16 | 17 | -------------------------------------------------------------------------------- /lang/observe/observe.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | object 6 | 20 | 21 | 22 |

                                                                  $.Observe Demo

                                                                  23 |

                                                                  Make changes to the JSON in the following textarea. 24 | Click Update Attrs to merge the JSON and see the events produced.

                                                                  25 |
                                                                  o = new $.Observe({})
                                                                  26 |
                                                                  o.attrs(
                                                                  27 | , true) 33 |
                                                                  
                                                                  34 | 	
                                                                  o.bind('change', function( ev, attr, how, newValue, prevValue, where ) { 
                                                                  35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
                                                                  attrhownewValueprevValuewhere
                                                                  45 | 46 | 47 | 50 | 82 | 83 | -------------------------------------------------------------------------------- /lang/observe/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                                  Observe Test Suite

                                                                  8 |

                                                                  9 |
                                                                  10 |

                                                                  11 |
                                                                    12 |
                                                                    13 | associations 14 | list 15 | 16 | 17 | -------------------------------------------------------------------------------- /lang/openajax/openajax.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Lang Performance Test 6 | 9 | 10 | 11 |
                                                                    12 |
                                                                    13 | 14 | 15 | 23 | 24 | -------------------------------------------------------------------------------- /lang/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                                    Lang Test Suite

                                                                    8 |

                                                                    9 |
                                                                    10 |

                                                                    11 |
                                                                      12 |
                                                                      13 | associations 14 | list 15 | 16 | 17 | -------------------------------------------------------------------------------- /lang/string/deparam/deparam.js: -------------------------------------------------------------------------------- 1 | steal('jquery', function($){ 2 | 3 | var digitTest = /^\d+$/, 4 | keyBreaker = /([^\[\]]+)|(\[\])/g, 5 | plus = /\+/g, 6 | paramTest = /([^?#]*)(#.*)?$/; 7 | 8 | /** 9 | * @add jQuery.String 10 | */ 11 | $.String = $.extend($.String || {}, { 12 | 13 | /** 14 | * @function deparam 15 | * 16 | * Takes a string of name value pairs and returns a Object literal that represents those params. 17 | * 18 | * @param {String} params a string like "foo=bar&person[age]=3" 19 | * @return {Object} A JavaScript Object that represents the params: 20 | * 21 | * { 22 | * foo: "bar", 23 | * person: { 24 | * age: "3" 25 | * } 26 | * } 27 | */ 28 | deparam: function(params){ 29 | 30 | if(! params || ! paramTest.test(params) ) { 31 | return {}; 32 | } 33 | 34 | 35 | var data = {}, 36 | pairs = params.split('&'), 37 | current; 38 | 39 | for(var i=0; i < pairs.length; i++){ 40 | current = data; 41 | var pair = pairs[i].split('='); 42 | 43 | // if we find foo=1+1=2 44 | if(pair.length != 2) { 45 | pair = [pair[0], pair.slice(1).join("=")] 46 | } 47 | 48 | var key = decodeURIComponent(pair[0].replace(plus, " ")), 49 | value = decodeURIComponent(pair[1].replace(plus, " ")), 50 | parts = key.match(keyBreaker); 51 | 52 | for ( var j = 0; j < parts.length - 1; j++ ) { 53 | var part = parts[j]; 54 | if (!current[part] ) { 55 | // if what we are pointing to looks like an array 56 | current[part] = digitTest.test(parts[j+1]) || parts[j+1] == "[]" ? [] : {} 57 | } 58 | current = current[part]; 59 | } 60 | lastPart = parts[parts.length - 1]; 61 | if(lastPart == "[]"){ 62 | current.push(value) 63 | }else{ 64 | current[lastPart] = value; 65 | } 66 | } 67 | return data; 68 | } 69 | }); 70 | 71 | }) 72 | -------------------------------------------------------------------------------- /lang/string/deparam/deparam_test.js: -------------------------------------------------------------------------------- 1 | steal('funcunit/qunit','./deparam').then(function(){ 2 | 3 | module('jquery/lang/deparam') 4 | 5 | test("Basic deparam",function(){ 6 | 7 | var data = $.String.deparam("a=b"); 8 | equals(data.a,"b") 9 | 10 | var data = $.String.deparam("a=b&c=d"); 11 | equals(data.a,"b") 12 | equals(data.c,"d") 13 | }) 14 | test("Nested deparam",function(){ 15 | 16 | var data = $.String.deparam("a[b]=1&a[c]=2"); 17 | equals(data.a.b,1) 18 | equals(data.a.c,2) 19 | 20 | var data = $.String.deparam("a[]=1&a[]=2"); 21 | equals(data.a[0],1) 22 | equals(data.a[1],2) 23 | 24 | var data = $.String.deparam("a[b][]=1&a[b][]=2"); 25 | equals(data.a.b[0],1) 26 | equals(data.a.b[1],2) 27 | 28 | var data = $.String.deparam("a[0]=1&a[1]=2"); 29 | equals(data.a[0],1) 30 | equals(data.a[1],2) 31 | }); 32 | 33 | 34 | test("deparam an array", function(){ 35 | var data = $.String.deparam("a[0]=1&a[1]=2"); 36 | 37 | ok($.isArray(data.a), "is array") 38 | 39 | equals(data.a[0],1) 40 | equals(data.a[1],2) 41 | }) 42 | 43 | test("deparam object with spaces", function(){ 44 | var data = $.String.deparam("a+b=c+d&+e+f+=+j+h+"); 45 | 46 | equals(data["a b"], "c d") 47 | equals(data[" e f "], " j h ") 48 | }) 49 | 50 | }) 51 | -------------------------------------------------------------------------------- /lang/string/deparam/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                                      Deparam Test Suite

                                                                      8 |

                                                                      9 |
                                                                      10 |

                                                                      11 |
                                                                        12 |
                                                                        13 | associations 14 | list 15 | 16 | 17 | -------------------------------------------------------------------------------- /lang/string/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | string QUnit Test 5 | 6 | 7 | 8 | 9 |

                                                                        string Test Suite

                                                                        10 |

                                                                        11 |
                                                                        12 |

                                                                        13 |
                                                                        14 |
                                                                          15 |
                                                                          16 | 17 | -------------------------------------------------------------------------------- /lang/string/rsplit/rsplit.js: -------------------------------------------------------------------------------- 1 | steal('jquery/lang/string',function( $ ) { 2 | /** 3 | * @add jQuery.String 4 | */ 5 | $.String. 6 | /** 7 | * Splits a string with a regex correctly cross browser 8 | * 9 | * $.String.rsplit("a.b.c.d", /\./) //-> ['a','b','c','d'] 10 | * 11 | * @param {String} string The string to split 12 | * @param {RegExp} regex A regular expression 13 | * @return {Array} An array of strings 14 | */ 15 | rsplit = function( string, regex ) { 16 | var result = regex.exec(string), 17 | retArr = [], 18 | first_idx, last_idx; 19 | while ( result !== null ) { 20 | first_idx = result.index; 21 | last_idx = regex.lastIndex; 22 | if ( first_idx !== 0 ) { 23 | retArr.push(string.substring(0, first_idx)); 24 | string = string.slice(first_idx); 25 | } 26 | retArr.push(result[0]); 27 | string = string.slice(result[0].length); 28 | result = regex.exec(string); 29 | } 30 | if ( string !== '' ) { 31 | retArr.push(string); 32 | } 33 | return retArr; 34 | }; 35 | }); -------------------------------------------------------------------------------- /lang/string/string.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | string 6 | 12 | 13 | 14 |

                                                                          string Demo

                                                                          15 |

                                                                          This is a dummy page to show off your plugin

                                                                          16 | 19 | 24 | 25 | -------------------------------------------------------------------------------- /lang/string/string_test.js: -------------------------------------------------------------------------------- 1 | steal('funcunit/qunit','./string').then(function(){ 2 | 3 | module("jquery/lang/string") 4 | 5 | test("$.String.sub", function(){ 6 | equals($.String.sub("a{b}",{b: "c"}),"ac") 7 | 8 | var foo = {b: "c"}; 9 | 10 | equals($.String.sub("a{b}",foo,true),"ac"); 11 | 12 | ok(!foo.b, "removed this b"); 13 | 14 | 15 | }); 16 | 17 | test("$.String.sub double", function(){ 18 | equals($.String.sub("{b} {d}",[{b: "c", d: "e"}]),"c e"); 19 | }) 20 | 21 | test("String.underscore", function(){ 22 | equals($.String.underscore("Foo.Bar.ZarDar"),"foo.bar.zar_dar") 23 | }) 24 | 25 | 26 | test("$.String.getObject", function(){ 27 | var obj = $.String.getObject("foo", [{a: 1}, {foo: 'bar'}]); 28 | 29 | equals(obj,'bar', 'got bar') 30 | 31 | 32 | // test null data 33 | 34 | var obj = $.String.getObject("foo", [{a: 1}, {foo: 0}]); 35 | 36 | equals(obj,0, 'got 0 (falsey stuff)') 37 | }); 38 | 39 | test("$.String.niceName", function(){ 40 | var str = "some_underscored_string"; 41 | var niceStr = $.String.niceName(str); 42 | equals(niceStr, 'Some Underscored String', 'got correct niceName'); 43 | }) 44 | 45 | 46 | }).then('./deparam/deparam_test'); 47 | -------------------------------------------------------------------------------- /model/backup/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 |

                                                                          Model Backup Test Suite

                                                                          14 |

                                                                          15 |
                                                                          16 |

                                                                          17 |
                                                                          18 |
                                                                            19 |
                                                                            20 | 21 | -------------------------------------------------------------------------------- /model/backup/qunit/qunit.js: -------------------------------------------------------------------------------- 1 | steal('funcunit/qunit') 2 | .then("jquery/model/backup").then(function(){ 3 | 4 | 5 | module("jquery/model/backup",{ 6 | setup : function(){ 7 | $.Model.extend("Recipe") 8 | } 9 | }) 10 | 11 | test("backing up", function(){ 12 | var recipe = new Recipe({name: "cheese"}); 13 | ok(!recipe.isDirty(), "not backedup, but clean") 14 | 15 | recipe.backup(); 16 | ok(!recipe.isDirty(), "backedup, but clean"); 17 | 18 | recipe.name = 'blah' 19 | 20 | ok(recipe.isDirty(), "dirty"); 21 | 22 | recipe.restore(); 23 | 24 | ok(!recipe.isDirty(), "restored, clean"); 25 | 26 | equals(recipe.name, "cheese" ,"name back"); 27 | 28 | }); 29 | 30 | test("backup / restore with associations", function(){ 31 | $.Model("Instruction"); 32 | $.Model("Cookbook"); 33 | 34 | $.Model("Recipe",{ 35 | attributes : { 36 | instructions : "Instruction.models", 37 | cookbook: "Cookbook.model" 38 | } 39 | },{}); 40 | 41 | 42 | 43 | 44 | var recipe = new Recipe({ 45 | name: "cheese burger", 46 | instructions : [ 47 | { 48 | description: "heat meat" 49 | }, 50 | { 51 | description: "add cheese" 52 | } 53 | ], 54 | cookbook: { 55 | title : "Justin's Grillin Times" 56 | } 57 | }); 58 | 59 | //test basic is dirty 60 | 61 | ok(!recipe.isDirty(), "not backedup, but clean") 62 | 63 | recipe.backup(); 64 | ok(!recipe.isDirty(), "backedup, but clean"); 65 | 66 | recipe.name = 'blah' 67 | 68 | ok(recipe.isDirty(), "dirty"); 69 | 70 | recipe.restore(); 71 | 72 | ok(!recipe.isDirty(), "restored, clean"); 73 | 74 | equals(recipe.name, "cheese burger" ,"name back"); 75 | 76 | // test belongs too 77 | 78 | ok(!recipe.cookbook.isDirty(), "cookbook not backedup, but clean"); 79 | 80 | recipe.cookbook.backup(); 81 | 82 | recipe.cookbook.attr("title","Brian's Burgers"); 83 | 84 | ok(!recipe.isDirty(), "recipe itself is clean"); 85 | 86 | ok(recipe.isDirty(true), "recipe is dirty if checking associations"); 87 | 88 | recipe.cookbook.restore() 89 | 90 | ok(!recipe.isDirty(true), "recipe is now clean with checking associations"); 91 | 92 | equals(recipe.cookbook.title, "Justin's Grillin Times" ,"cookbook title back"); 93 | 94 | //try belongs to recursive restore 95 | 96 | recipe.cookbook.attr("title","Brian's Burgers"); 97 | recipe.restore(); 98 | ok(recipe.isDirty(true), "recipe is dirty if checking associations, after a restore"); 99 | 100 | recipe.restore(true); 101 | ok(!recipe.isDirty(true), "cleaned all of recipe and its associations"); 102 | 103 | 104 | }) 105 | 106 | }) 107 | -------------------------------------------------------------------------------- /model/demo-convert.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Model Convert Demo 6 | 12 | 13 | 14 |
                                                                            15 |

                                                                            Model Convert Demo

                                                                            16 |

                                                                            This demo shows converting date strings sent by the 17 | server to JavaScript dates with attributes and convert.

                                                                            18 |
                                                                            19 |
                                                                            20 |
                                                                              21 |
                                                                              22 | 25 | 76 | 77 | -------------------------------------------------------------------------------- /model/demo-dom.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Model Convert Demo 6 | 12 | 13 | 14 |
                                                                              15 |

                                                                              Model DOM Helpers Demo

                                                                              16 |

                                                                              This demo shows using models to set an instance on an element.

                                                                              17 |
                                                                              18 |
                                                                              19 |
                                                                                20 |
                                                                                21 | 24 | 80 | 81 | -------------------------------------------------------------------------------- /model/demo-setter.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Model Events Demo 6 | 12 | 13 | 14 |
                                                                                15 |

                                                                                Model Setter Demo

                                                                                16 |

                                                                                This demo shows converting date strings sent by the 17 | server to JavaScript dates with Setters.

                                                                                18 |
                                                                                19 |
                                                                                20 |
                                                                                  21 |
                                                                                  22 | 25 | 26 | 77 | 78 | -------------------------------------------------------------------------------- /model/fixtures/school.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 4, 3 | "name" : "Highland" 4 | } -------------------------------------------------------------------------------- /model/fixtures/schools.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id": 1, 3 | "name" : "adler" 4 | }] 5 | -------------------------------------------------------------------------------- /model/list/cookie/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 |

                                                                                  Model List Cookie Test Suite

                                                                                  14 |

                                                                                  15 |
                                                                                  16 |

                                                                                  17 |
                                                                                  18 |
                                                                                    19 |
                                                                                    20 | 21 | -------------------------------------------------------------------------------- /model/list/cookie/qunit/qunit.js: -------------------------------------------------------------------------------- 1 | steal('funcunit/qunit','jquery/model/list/cookie').then(function($){ 2 | 3 | module("jquery/model/list/cookie",{ 4 | setup: function(){ 5 | // clear any existing cookie ... 6 | $.cookie("list", "", {expires: -1}) 7 | $.Model.extend("Search", {}, {}); 8 | 9 | $.Model.List.Cookie.extend("Search.Store") 10 | } 11 | }) 12 | 13 | test("storing and retrieving",function(){ 14 | 15 | var store = new Search.Store([]) //should be able to look up by namespace .... 16 | 17 | ok(!store.length, "empty list"); 18 | 19 | store.push( new Search({id: 1}), new Search({id: 2}) ) 20 | store.store("list"); 21 | 22 | var store2 = new Search.Store([]).retrieve("list"); 23 | equals(store2.length, 2, "there are 2 items") 24 | 25 | }) 26 | 27 | }) 28 | -------------------------------------------------------------------------------- /model/list/local/local.js: -------------------------------------------------------------------------------- 1 | steal('jquery/dom/cookie','jquery/model/list').then(function($){ 2 | /** 3 | * @class jQuery.Model.List.Local 4 | * @plugin jquery/model/list/local 5 | * @download http://jmvcsite.heroku.com/pluginify?plugins[]=jquery/model/list/local/local.js 6 | * @parent jQuery.Model.List 7 | * Works exactly the same as [jQuery.Model.List.Cookie] except uses 8 | * a local store instead of cookies. 9 | */ 10 | $.Model.List("jQuery.Model.List.Local", 11 | { 12 | retrieve : function(name){ 13 | // each also needs what they are referencd by ? 14 | var props = window.localStorage[ name ] || "[]", 15 | instances = [], 16 | Class = props.type ? $.String.getObject(props.type) : null; 17 | for(var i =0; i < props.ids.length;i++){ 18 | var identity = props.ids[i], 19 | instanceData = window.localStorage[ identity ]; 20 | instances.push( new Class(instanceData) ) 21 | } 22 | this.push.apply(this,instances); 23 | return this; 24 | }, 25 | store : function(name){ 26 | // go through and listen to instance updating 27 | var ids = [], days = this.days; 28 | this.each(function(i, inst){ 29 | window.localStorage[inst.identity()] = inst.attrs(); 30 | ids.push(inst.identity()); 31 | }); 32 | window.localStorage[name] = { 33 | type: this[0] && this[0].constructor.fullName, 34 | ids: ids 35 | }; 36 | return this; 37 | } 38 | 39 | }); 40 | 41 | }) 42 | 43 | -------------------------------------------------------------------------------- /model/list/memory.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | List Helper Demo 6 | 12 | 13 | 14 | Start 15 |
                                                                                    16 | 17 | 18 | 21 | 86 | 87 | -------------------------------------------------------------------------------- /model/list/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

                                                                                    Model List Test Suite

                                                                                    9 |

                                                                                    10 |
                                                                                    11 |

                                                                                    12 |
                                                                                    13 |
                                                                                      14 |
                                                                                      15 | 16 | -------------------------------------------------------------------------------- /model/modelBinder.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | slider 6 | 23 | 24 | 25 |
                                                                                      26 | 27 | 28 | 29 | 30 | 31 | 32 | 44 | 47 | 48 | 91 | 92 | -------------------------------------------------------------------------------- /model/pages/deferreds.md: -------------------------------------------------------------------------------- 1 | @page jquery.model.deferreds Deferreds 2 | @parent jQuery.Model 3 | 4 | Models (and views) work 5 | with [http://api.jquery.com/category/deferred-object/ jQuery.Deferred]. If 6 | you properly fill out a model's [jquery.model.services service API], asynchronous 7 | requests done via the model will return a jQuery.Deferred. 8 | 9 | ## findAll example 10 | 11 | The following example, requests tasks and people and waits for both requests 12 | to be complete before alerting the user: 13 | 14 | var tasksDef = Task.findAll(), 15 | peopleDef = People.findAll(); 16 | 17 | $.when(tasksDef,peopleDef).done(function(taskResponse, peopleResponse){ 18 | alert("There are "+taskRespone[0].length+" tasks and "+ 19 | peopleResponse[0].length+" people."); 20 | }); 21 | 22 | __Note__ taskResponse[0] is an Array of tasks. 23 | 24 | ## save and destroy example 25 | 26 | Calls to [jQuery.Model.prototype.save save] and [jQuery.Model.prototype.destroy] also 27 | return a deferred. The deferred is resolved to the newly created, destroyed, or updated 28 | model instance. 29 | 30 | The following creates a task, updates it, and destroys it: 31 | 32 | var taskD = new Task({name: "dishes"}).save(); 33 | 34 | taskD.done(function(task){ 35 | 36 | var taskD2 = task.update({name: "all the dishes"}) 37 | 38 | taskD2.done(function(task){ 39 | 40 | var taskD3 = task.destroy(); 41 | 42 | taskD3.done(function(){ 43 | console.log("task destroyed"); 44 | }) 45 | 46 | }) 47 | 48 | }); 49 | -------------------------------------------------------------------------------- /model/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                                                      Model Test Suite

                                                                                      8 |

                                                                                      9 |
                                                                                      10 |

                                                                                      11 |
                                                                                        12 |
                                                                                        13 | associations 14 | list 15 | 16 | 17 | -------------------------------------------------------------------------------- /model/service/service.js: -------------------------------------------------------------------------------- 1 | steal('jquery/model').then(function(){ 2 | var convert = function(method, func){ 3 | 4 | return typeof method == 'function' ? function(){ 5 | var old = this._service, 6 | ret; 7 | this._service = func; 8 | ret = method.apply(this, arguments); 9 | this._service = old; 10 | return ret; 11 | } : method 12 | } 13 | /** 14 | * Creates a service 15 | * @param {Object} defaults 16 | * @param {Object} methods 17 | */ 18 | $.Model.service = function(properties){ 19 | 20 | var func = function(newProps){ 21 | return $.Model.service( $.extend({}, properties, newProps) ); 22 | }; 23 | 24 | for(var name in properties){ 25 | func[name] = convert(properties[name], func) 26 | } 27 | 28 | return func; 29 | } 30 | }); 31 | -------------------------------------------------------------------------------- /model/service/twitter/twitter.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | associations 6 | 12 | 13 | 14 |

                                                                                        JavaScriptMVC Tweets

                                                                                        15 |
                                                                                          16 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /model/service/twitter/twitter.js: -------------------------------------------------------------------------------- 1 | steal('jquery/model/service').then(function(){ 2 | 3 | $.Model.service.twitter = $.Model.service({ 4 | url : "http://api.twitter.com/1/", 5 | select : "*", 6 | from : "statuses/user_timeline.json", 7 | where : {screen_name : "javascriptmvc"}, 8 | /** 9 | * 10 | * @param {Object} params 11 | */ 12 | findAll : function(params, success, error){ 13 | 14 | 15 | var url = (params.url || this._service.url)+(params.from || this._service.from), 16 | self = this; 17 | 18 | var twitterJson = { 19 | url: url, 20 | dataType: "jsonp", 21 | data: params.where || this._service.where, 22 | error : error 23 | } 24 | 25 | if(this.wrapMany){ 26 | twitterJson.success = function (data) { 27 | if(data.results){ 28 | data = data.results 29 | } 30 | success(self.wrapMany(data)) 31 | 32 | } 33 | }else{ 34 | twitterJson.success = success; 35 | } 36 | 37 | $.ajax(twitterJson); 38 | } 39 | }); 40 | 41 | }) 42 | 43 | 44 | -------------------------------------------------------------------------------- /model/service/yql/yql.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | associations 6 | 12 | 13 | 14 | 19 | 26 | 27 | -------------------------------------------------------------------------------- /model/service/yql/yql.js: -------------------------------------------------------------------------------- 1 | steal('jquery/model/service').then(function(){ 2 | 3 | $.Model.service.yql = $.Model.service({ 4 | select : "*", 5 | from : "flickr.photos.search", 6 | convert : function (query, params) { 7 | $.each( params, function (key) { 8 | var name = new RegExp( "#\{" + key + "\}","g" ); 9 | var value = $.trim(this); 10 | //if (!value.match(/^[0-9]+$/)) { 11 | // value = '"' + value + '"'; 12 | //} 13 | query = query.replace(name, value); 14 | } 15 | ); 16 | return query; 17 | }, 18 | /** 19 | * 20 | * @param {Object} params 21 | */ 22 | findAll : function(params, success, error){ 23 | params = $.extend({}, this._service, params); 24 | var query = ["SELECT",params.select,"FROM",params.from]; 25 | 26 | 27 | if(params.where){ 28 | query.push("WHERE",typeof params.where == "string" || this._service.convert(params.where[0],params.where[1])) 29 | } 30 | var self = this; 31 | 32 | 33 | var yqlJson = { 34 | url: "http://query.yahooapis.com/v1/public/yql", 35 | dataType: "jsonp", 36 | data: { 37 | q: query.join(" "), 38 | format: "json", 39 | env: 'store://datatables.org/alltableswithkeys', 40 | callback: "?" 41 | } 42 | } 43 | if (error) { 44 | yqlJson.error = error; 45 | } 46 | if(this.wrapMany){ 47 | yqlJson.success = function (data) { 48 | var results = data.query.results 49 | if(results){ 50 | for(var name in results){ 51 | success(self.wrapMany(data.query.results[name])); 52 | break; 53 | } 54 | }else{ 55 | success([]); 56 | } 57 | } 58 | }else{ 59 | yqlJson.success = success; 60 | } 61 | 62 | $.ajax(yqlJson); 63 | } 64 | }); 65 | 66 | }) -------------------------------------------------------------------------------- /model/store/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | store QUnit Test 5 | 6 | 7 | 8 | 9 |

                                                                                          store Test Suite

                                                                                          10 |

                                                                                          11 |
                                                                                          12 |

                                                                                          13 |
                                                                                          14 |
                                                                                            15 |
                                                                                            16 | 17 | -------------------------------------------------------------------------------- /model/test/4.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 4, 3 | "name" : "adler" 4 | } -------------------------------------------------------------------------------- /model/test/create.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 4, 3 | "name" : "Highland" 4 | } -------------------------------------------------------------------------------- /model/test/people.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id" : 5, 3 | "name" : "Justin" 4 | }] 5 | -------------------------------------------------------------------------------- /model/test/person.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : 5, 3 | "name" : "Justin" 4 | } 5 | -------------------------------------------------------------------------------- /model/test/qunit/findAll.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id" : 1, 3 | "name" : "Thing 1" 4 | }] 5 | -------------------------------------------------------------------------------- /model/test/qunit/qunit.js: -------------------------------------------------------------------------------- 1 | //we probably have to have this only describing where the tests are 2 | steal("jquery/model","jquery/dom/fixture") //load your app 3 | .then('funcunit/qunit') //load qunit 4 | .then("./model_test.js")//,"./associations_test.js") 5 | .then( 6 | "jquery/model/backup/qunit", 7 | "jquery/model/list/list_test.js" 8 | ) 9 | .then("jquery/model/validations/qunit/validations_test.js") 10 | -------------------------------------------------------------------------------- /model/test/schools.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id": 1, 3 | "name" : "adler" 4 | }] 5 | -------------------------------------------------------------------------------- /model/test/update4.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 4, 3 | "name" : "LHS" 4 | } -------------------------------------------------------------------------------- /model/validations/demo.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Model Validations Demo 6 | 12 | 13 | 14 |
                                                                                            15 | 16 |
                                                                                            17 |
                                                                                            18 | 21 | 104 | 105 | -------------------------------------------------------------------------------- /model/validations/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

                                                                                            Model Test Suite

                                                                                            8 |

                                                                                            9 |
                                                                                            10 |

                                                                                            11 |
                                                                                              12 |
                                                                                              13 | associations 14 | list 15 | 16 | 17 | -------------------------------------------------------------------------------- /qunit.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | jQueryMX Test 7 | 8 | 9 | 10 |

                                                                                              JavaScriptMVC jQuery Test Suite

                                                                                              11 |

                                                                                              12 |
                                                                                              13 |

                                                                                              14 |
                                                                                                15 |
                                                                                                16 | 17 | 18 | -------------------------------------------------------------------------------- /test/qunit/integration.js: -------------------------------------------------------------------------------- 1 | steal('funcunit/qunit', 2 | 'jquery/model', 3 | 'jquery/controller', 4 | 'jquery/view/ejs', 5 | 'jquery/dom/fixture') 6 | .then(function(){ 7 | 8 | module('integration',{ 9 | setup : function(){ 10 | $("#qunit-test-area").html("") 11 | } 12 | }); 13 | 14 | test("controller can listen to model instances and model classes", function(){ 15 | 16 | 17 | $("#qunit-test-area").html(""); 18 | 19 | 20 | 21 | $.Controller("Test.BinderThing",{ 22 | "{model} created" : function(){ 23 | ok(true,"model called"); 24 | start(); 25 | }, 26 | "{instance} created" : function(){ 27 | ok(true, "instance updated") 28 | } 29 | }); 30 | 31 | $.Model("Test.ModelThing",{ 32 | create : function(attrs, success){ 33 | success({id: 1}) 34 | } 35 | }); 36 | 37 | 38 | var inst = new Test.ModelThing(); 39 | 40 | $("
                                                                                                ").appendTo( $("#qunit-test-area") ) 41 | .test_binder_thing({ 42 | model : Test.ModelThing, 43 | instance: inst 44 | }); 45 | 46 | inst.save(); 47 | stop(); 48 | }) 49 | 50 | 51 | test("Model and Views", function(){ 52 | stop(); 53 | 54 | $.Model("Test.Thing",{ 55 | findOne : "/thing" 56 | },{}) 57 | 58 | $.fixture("/thing","//jquery/test/thing.json") 59 | 60 | var res = $.View("//jquery/test/template.ejs", 61 | Test.Thing.findOne()); 62 | 63 | res.done(function(resolved){ 64 | equals(resolved,"foo","works") 65 | start() 66 | }) 67 | }) 68 | 69 | }) 70 | -------------------------------------------------------------------------------- /test/qunit/qunit.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var isReady, 3 | stateAfterScript; 4 | 5 | //we probably have to have this only describing where the tests are 6 | steal('jquery').then(function(){ 7 | $(function(){ 8 | isReady = true; 9 | }) 10 | },'jquery/class/class_test.js') 11 | .then('jquery/controller/controller_test.js') 12 | .then('jquery/dom/compare/compare_test.js') 13 | .then('jquery/dom/cur_styles/cur_styles_test.js') 14 | .then('jquery/dom/dimensions/dimensions_test.js') 15 | .then('jquery/dom/form_params/form_params_test.js') 16 | .then('jquery/dom/route/route_test.js') 17 | .then('jquery/lang/lang_test.js') 18 | .then('jquery/dom/fixture/fixture_test.js') 19 | .then('jquery/event/default/default_test.js') 20 | .then('jquery/event/destroyed/destroyed_test.js') 21 | .then('jquery/event/drag/drag_test.js') 22 | .then('jquery/event/hover/hover_test.js') 23 | .then('jquery/event/key/key_test.js') 24 | .then('jquery/tie/tie_test.js') 25 | .then('jquery/controller/view/test/qunit') 26 | .then('jquery/model/test/qunit') 27 | .then('jquery/view/test/qunit') 28 | .then('./integration.js') 29 | .then('jquery/event/default/default_pause_test.js',function(){ 30 | 31 | stateAfterScript = isReady; 32 | module('jquery v steal'); 33 | 34 | 35 | test("jquery isn't ready", function(){ 36 | ok(!stateAfterScript, "jQuery isn't ready yet") 37 | }) 38 | 39 | }); 40 | 41 | })(); 42 | -------------------------------------------------------------------------------- /test/run.js: -------------------------------------------------------------------------------- 1 | // loads all of jquerymx's command line tests 2 | 3 | //load("jquery/download/test/run.js"); 4 | 5 | load('jquery/view/test/compression/run.js'); 6 | 7 | load("jquery/generate/test/run.js"); 8 | 9 | -------------------------------------------------------------------------------- /test/template.ejs: -------------------------------------------------------------------------------- 1 | <%= name %> -------------------------------------------------------------------------------- /test/thing.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" :1, 3 | "name": "foo" 4 | } 5 | -------------------------------------------------------------------------------- /tie/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | tie QUnit Test 5 | 8 | 9 | 10 | 11 | 12 |

                                                                                                tie Test Suite

                                                                                                13 |

                                                                                                14 |
                                                                                                15 |

                                                                                                16 |
                                                                                                17 |
                                                                                                  18 |
                                                                                                  19 | 20 | -------------------------------------------------------------------------------- /tie/tie.js: -------------------------------------------------------------------------------- 1 | steal('jquery/controller').then(function($){ 2 | 3 | /** 4 | * @class jQuery.Tie 5 | * @core 6 | * 7 | * The $.fn.tie plugin binds form elements and controllers with 8 | * models and vice versa. The result is that a change in 9 | * a model will automatically update the form element or controller 10 | * AND a change event on the element will update the model. 11 | * 12 | * 13 | * 14 | * 15 | * 16 | */ 17 | $.Controller("jQuery.Tie",{ 18 | setup : function(el){ 19 | this._super(el,{}) 20 | return $.makeArray(arguments); 21 | }, 22 | init : function(el, inst, attr, type){ 23 | // if there's a controller 24 | if(!type){ 25 | //find the first one that implements val 26 | var controllers = this.element.data("controllers") || {}; 27 | for(var name in controllers){ 28 | var controller = controllers[name]; 29 | if(typeof controller.val == 'function'){ 30 | type = name; 31 | break; 32 | } 33 | } 34 | } 35 | 36 | this.type = type; 37 | this.attr = attr; 38 | this.inst = inst; 39 | this.bind(inst, attr, "attrChanged"); 40 | 41 | //destroy this controller if the model instance is destroyed 42 | this.bind(inst, "destroyed", "modelDestroyed"); 43 | 44 | var value = inst.attr(attr); 45 | //set the value 46 | this.lastValue = value; 47 | if(type){ 48 | 49 | //destroy this controller if the controller is destroyed 50 | this.bind(this.element.data("controllers")[type],"destroyed","destroy"); 51 | this.element[type]("val",value); 52 | 53 | }else{ 54 | this.element.val(value) 55 | } 56 | }, 57 | attrChanged : function(inst, ev, val){ 58 | if (val !== this.lastValue) { 59 | this.setVal(val); 60 | this.lastValue = val; 61 | } 62 | }, 63 | modelDestroyed : function(){ 64 | this.destroy() 65 | }, 66 | setVal : function(val){ 67 | if (this.type) { 68 | this.element[this.type]("val", val) 69 | } 70 | else { 71 | this.element.val(val) 72 | } 73 | }, 74 | change : function(el, ev, val){ 75 | if(!this.type && val === undefined){ 76 | val = this.element.val(); 77 | } 78 | 79 | this.inst.attr(this.attr, val, null, this.proxy('setBack')) 80 | 81 | }, 82 | setBack : function(){ 83 | this.setVal(this.lastValue); 84 | }, 85 | destroy : function(){ 86 | this.inst = null; 87 | if(! this._destroyed ){ 88 | // assume it's because of the https://github.com/jupiterjs/jquerymx/pull/20 89 | // problem and don't throw an error 90 | this._super(); 91 | } 92 | 93 | } 94 | }); 95 | 96 | 97 | }); -------------------------------------------------------------------------------- /update: -------------------------------------------------------------------------------- 1 | load('steal/rhino/rhino.js') 2 | 3 | steal('steal/get', function(s) { 4 | s.get('http://github.com/jupiterjs/jquerymx/', {name: 'jquery'}); 5 | }) 6 | -------------------------------------------------------------------------------- /view/compress.js: -------------------------------------------------------------------------------- 1 | //js view/compress.js 2 | 3 | var compressPage = 'view/view.html'; 4 | var outputFolder = 'view'; 5 | load("steal/compress/compress.js") 6 | var compress = new Steal.Compress([compressPage, outputFolder]); 7 | compress.init(); -------------------------------------------------------------------------------- /view/ejs/easyhookup.ejs: -------------------------------------------------------------------------------- 1 |
                                                                                                  el.addClass(text) %>> -------------------------------------------------------------------------------- /view/ejs/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 |

                                                                                                  ejs Test Suite

                                                                                                  14 |

                                                                                                  15 |
                                                                                                  16 |

                                                                                                  17 |
                                                                                                  18 |
                                                                                                    19 |
                                                                                                    20 | 21 | -------------------------------------------------------------------------------- /view/ejs/test_template.ejs: -------------------------------------------------------------------------------- 1 | <%# Test Something Produces Items%> 2 | <%== something(function(items){ %> 3 | <%== items.length%> 4 | <% $.each(items, function(){ %><%# Test Something Produces Items%> 5 | <%== something(function(items){ %>ItemsLength<%== items.length %><% }) %> 6 | <% }) %> 7 | <% }) %> 8 | <% for( var i =0; i < items.length; i++) { %>for <%= items[i] %><% } %> -------------------------------------------------------------------------------- /view/micro/micro.js: -------------------------------------------------------------------------------- 1 | steal('jquery/view').then(function(){ 2 | // Simple JavaScript Templating 3 | // John Resig - http://ejohn.org/ - MIT Licensed 4 | 5 | var cache = {}; 6 | /** 7 | * @function Micro 8 | * @parent jQuery.View 9 | * @plugin jquery/view/micro 10 | * A very lightweight template engine. 11 | * Magic tags look like: 12 | * 13 | * @codestart 14 | *

                                                                                                    {%= message %}

                                                                                                    15 | * @codeend 16 | * 17 | * Micro is integrated in JavaScriptMVC so 18 | * you can use it like: 19 | * 20 | * @codestart 21 | * $("#foo").html('//app/views/bar.micro',{}); 22 | * @codeend 23 | * 24 | * ## Pros 25 | * 26 | * - Very Lightweight 27 | * 28 | * ## Cons 29 | * 30 | * - Doesn't handle nested tags. 31 | * - Doesn't handle {%= "%}" %}. 32 | * - More difficult to debug. 33 | * - Removes newlines and tabs. 34 | * 35 | * ## Use 36 | * 37 | * For more information on micro, see John Resig's 38 | * [http://ejohn.org/blog/javascript-micro-templating/ write up]. 39 | * 40 | * @param {String} str template content. 41 | * @param {Object} data render's the template with this content. 42 | */ 43 | function Micro(str, data){ 44 | var body = 45 | "var p=[],print=function(){p.push.apply(p,arguments);};" + 46 | 47 | // Introduce the data as local variables using with(){} 48 | "with(obj){p.push('" + 49 | 50 | // Convert the template into pure JavaScript 51 | str.replace(/[\r\t\n]/g, " ") 52 | .replace(/'(?=[^%]*%})/g,"\t") 53 | .split("'").join("\\'") 54 | .split("\t").join("'") 55 | .replace(/{%=(.+?)%}/g, "',$1,'") 56 | .split("{%").join("');") 57 | .split("%}").join("p.push('")+ "');}return p.join('');" 58 | 59 | var fn = new Function("obj",body); 60 | fn.body = body; 61 | 62 | // Provide some basic currying to the user 63 | return data ? fn( data ) : fn; 64 | }; 65 | 66 | $.View.register({ 67 | suffix : "micro", 68 | renderer: function( id, text ) { 69 | var mt = Micro(text) 70 | return function(data){ 71 | return mt(data) 72 | } 73 | }, 74 | script: function( id, str ) { 75 | return "function(obj){"+Micro(str).body+"}"; 76 | } 77 | }) 78 | jQuery.View.ext = ".micro" 79 | 80 | 81 | }); -------------------------------------------------------------------------------- /view/pages/deferreds.md: -------------------------------------------------------------------------------- 1 | @page view.deferreds Using Deferreds with Views 2 | @parent jQuery.View 1 3 | 4 | jQuery 1.6 brought [http://api.jquery.com/category/deferred-object/ Deferred] support. They are a great feature that promise to make a lot of asynchronous functionality easier to write and manage. jQuery.View uses Deferreds to simplify a common but annoying task into a one-liner: loading data and a template and rendering the result into an element. 5 | 6 | ## Templates Consume Deferreds 7 | 8 | Here's what rendering templates looks like with deferreds: 9 | 10 | $('#todos').html('temps/todos.ejs', $.get('/todos',{},'json') ); 11 | 12 | This will make two parallel ajax requests. One request 13 | is made for the template at `temps/todos.ejs`: 14 | 15 |
                                                                                                    <% for(var i =0; i < this.length; i++) { %>
                                                                                                    16 |   <li><%= this[i].name %></li>
                                                                                                    17 | <% } %>
                                                                                                    18 | 
                                                                                                    19 | 20 | The second request for `/todos` might respond with a JSON array: 21 | 22 | [ 23 | {"id" : 1, "name": "Take out the Trash"}, 24 | {"id" : 2, "name": "Do the Laundry"} 25 | ] 26 | 27 | When both have been loaded, the template is rendered with the todos data. The resulting HTML is placed in the `#todos` element. 28 | 29 | This is fab fast! The AJAX and template request are made in parallel and rendered 30 | when both are complete. Before deferreds, this was a lot uglier: 31 | 32 | var template, 33 | data, 34 | done = function(){ 35 | if( template && data ) { 36 | var html = new EJS({text: template}) 37 | .render(data); 38 | $('#todos').html( html ) 39 | } 40 | } 41 | $.get('temps/todos.ejs', function(text){ 42 | template = text; 43 | done(); 44 | },'text') 45 | $.get('/todos',{}, function(json){ 46 | data = json 47 | done(); 48 | },'json') 49 | 50 | ## Models Return Deferreds 51 | 52 | Model AJAX functions now return deferreds. Creating models like: 53 | 54 | $.Model('User',{ 55 | findAll: '/users' 56 | },{}); 57 | 58 | $.Model('Todo',{ 59 | findAll: '/todos' 60 | },{}) 61 | 62 | Lets you request todos and users and get back a deferred that can be 63 | used in functions that accept deferreds like $.when: 64 | 65 | $.when( User.findAll(), 66 | Todo.findAll() ) 67 | 68 | Or $.View: 69 | 70 | $('#content').html('temps/content.ejs',{ 71 | users : User.findAll(), 72 | todos: Todo.findAll() 73 | }) -------------------------------------------------------------------------------- /view/qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

                                                                                                    view Test Suite

                                                                                                    9 |

                                                                                                    10 |
                                                                                                    11 |

                                                                                                    12 |
                                                                                                    13 |
                                                                                                      14 |
                                                                                                      15 | 16 | -------------------------------------------------------------------------------- /view/test/compression/compression.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | compression 6 | 7 |
                                                                                                      8 | 11 | 12 | -------------------------------------------------------------------------------- /view/test/compression/compression.js: -------------------------------------------------------------------------------- 1 | steal('jquery/view/ejs', 'jquery/view/tmpl') 2 | .then('./views/relative.ejs', 3 | 'jquery/view/test/compression/views/absolute.ejs', 4 | './views/tmplTest.tmpl', 5 | './views/test.ejs', 6 | function(){ 7 | 8 | $(document).ready(function(){ 9 | $("#target").append('//jquery/view/test/compression/views/relative.ejs', {}) 10 | .append($.View('//jquery/view/test/compression/views/absolute.ejs', {} )) 11 | .append($.View('//jquery/view/test/compression/views/tmplTest.tmpl', {message: "Jquery Tmpl"} )) 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /view/test/compression/run.js: -------------------------------------------------------------------------------- 1 | // load('steal/compress/test/run.js') 2 | 3 | /** 4 | * Tests compressing a very basic page and one that is using steal 5 | */ 6 | 7 | load('steal/rhino/rhino.js') 8 | steal('steal/test', function(s){ 9 | 10 | s.test.module("jquery/view/compression") 11 | STEALPRINT = false; 12 | 13 | s.test.test("templates" , function(t){ 14 | 15 | 16 | steal.File("jquery/view/test/compression/views/absolute.ejs").save("

                                                                                                      Absolute

                                                                                                      \n

                                                                                                      ok

                                                                                                      "); 17 | steal.File("jquery/view/test/compression/views/relative.ejs").save("

                                                                                                      Relative

                                                                                                      "); 18 | steal.File("jquery/view/test/compression/views/tmplTest.tmpl").save("

                                                                                                      ${message}

                                                                                                      "); 19 | s.test.clear(); 20 | 21 | load("steal/rhino/rhino.js"); 22 | steal('steal/build','steal/build/scripts',function(){ 23 | steal.build('jquery/view/test/compression/compression.html',{to: 'jquery/view/test/compression'}); 24 | }); 25 | s.test.clear(); 26 | s.test.remove("jquery/view/test/compression/views/absolute.ejs") 27 | s.test.remove("jquery/view/test/compression/views/relative.ejs") 28 | s.test.remove("jquery/view/test/compression/views/tmplTest.tmpl") 29 | 30 | 31 | steal = {env: "production"}; 32 | 33 | s.test.open('jquery/view/test/compression/compression.html') 34 | s.test.ok( /Relative/i.test( $(document.body).text() ), "Relative not in page!" ); 35 | 36 | s.test.ok( /Absolute/i.test( $(document.body).text() ), "Absolute not in page!" ); 37 | 38 | s.test.ok( /Jquery Tmpl/i.test( $(document.body).text() ), "Jquery Tmpl not in page!" ); 39 | 40 | s.test.clear(); 41 | s.test.remove("jquery/view/test/compression/production.js") 42 | 43 | }) 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | }); -------------------------------------------------------------------------------- /view/test/compression/views/keep.me: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupiterjs/jquerymx/0f917a85327a6c0196c2cf28c1d90a9095e0eae1/view/test/compression/views/keep.me -------------------------------------------------------------------------------- /view/test/compression/views/test.ejs: -------------------------------------------------------------------------------- 1 | <%for(var i = 0; i < 5 ; i++){%> 2 |
                                                                                                    1. hi
                                                                                                    2. 3 | <%}%> -------------------------------------------------------------------------------- /view/test/qunit/deferred.ejs: -------------------------------------------------------------------------------- 1 | <%= foo %> -------------------------------------------------------------------------------- /view/test/qunit/deferreds.ejs: -------------------------------------------------------------------------------- 1 | <%= foo %> and <%= bar %> -------------------------------------------------------------------------------- /view/test/qunit/hookup.ejs: -------------------------------------------------------------------------------- 1 |
                                                                                                      /> -------------------------------------------------------------------------------- /view/test/qunit/hookupvalcall.ejs: -------------------------------------------------------------------------------- 1 | 4 |
                                                                                                      >
                                                                                                      -------------------------------------------------------------------------------- /view/test/qunit/nested_plugin.ejs: -------------------------------------------------------------------------------- 1 |
                                                                                                      id='something'>
                                                                                                      -------------------------------------------------------------------------------- /view/test/qunit/plugin.ejs: -------------------------------------------------------------------------------- 1 |
                                                                                                      Here is something")%> id='something'>
                                                                                                      -------------------------------------------------------------------------------- /view/test/qunit/qunit.js: -------------------------------------------------------------------------------- 1 | //we probably have to have this only describing where the tests are 2 | steal("jquery/view","jquery/view/micro","jquery/view/ejs/ejs_test.js","jquery/view/jaml","jquery/view/tmpl") //load your app 3 | .then('funcunit/qunit') //load qunit 4 | .then("./view_test.js","jquery/view/tmpl/tmpl_test.js") 5 | 6 | if(steal.isRhino){ 7 | steal('funcunit/qunit/rhino') 8 | } -------------------------------------------------------------------------------- /view/test/qunit/temp.ejs: -------------------------------------------------------------------------------- 1 |

                                                                                                      <%= message %>

                                                                                                      2 | -------------------------------------------------------------------------------- /view/test/qunit/template.ejs: -------------------------------------------------------------------------------- 1 |

                                                                                                      <%= message %>

                                                                                                      2 | -------------------------------------------------------------------------------- /view/test/qunit/template.jaml: -------------------------------------------------------------------------------- 1 | function(data) { 2 | h3(data.message); 3 | } -------------------------------------------------------------------------------- /view/test/qunit/template.micro: -------------------------------------------------------------------------------- 1 |

                                                                                                      {%= message %}

                                                                                                      2 | -------------------------------------------------------------------------------- /view/test/qunit/template.tmpl: -------------------------------------------------------------------------------- 1 |

                                                                                                      ${message}

                                                                                                      -------------------------------------------------------------------------------- /view/tmpl/test.tmpl: -------------------------------------------------------------------------------- 1 | {{if 1}}

                                                                                                      Hello World

                                                                                                      {{/if}} -------------------------------------------------------------------------------- /view/tmpl/tmpl_test.js: -------------------------------------------------------------------------------- 1 | steal('funcunit/qunit','jquery/view/tmpl').then(function(){ 2 | // use the view/qunit.html test to run this test script 3 | module("jquery/view/tmpl") 4 | 5 | test("ifs work", function(){ 6 | $("#qunit-test-area").html(""); 7 | 8 | $("#qunit-test-area").html("//jquery/view/tmpl/test.tmpl",{}); 9 | ok($("#qunit-test-area").find('h1').length, "There's an h1") 10 | }) 11 | }); 12 | -------------------------------------------------------------------------------- /view/view.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | view 6 | 7 | 27 | 28 | 29 |

                                                                                                      JAML

                                                                                                      30 |
                                                                                                      $("#jaml").html("template.jaml",{message: "Hello World"})
                                                                                                      31 |
                                                                                                      function(data) {
                                                                                                      32 |   h3(data.message);
                                                                                                      33 | }
                                                                                                      34 |
                                                                                                      35 |

                                                                                                      EJS

                                                                                                      36 |
                                                                                                      $("#ejs").html("template.ejs",{message: "Hello World"})
                                                                                                      37 |
                                                                                                      <h3><%= message %></h3>
                                                                                                      38 |
                                                                                                      39 |

                                                                                                      MICRO

                                                                                                      40 |
                                                                                                      $("#micro").html("template.micro",{message: "Hello World"})
                                                                                                      41 |
                                                                                                      <h3>{%= message %}</h3>
                                                                                                      42 |
                                                                                                      43 |

                                                                                                      TMPL

                                                                                                      44 |
                                                                                                      $("#tmpl").html("template.tmpl",{message: "Hello World"})
                                                                                                      45 |
                                                                                                      <h3>{%= message %}</h3>
                                                                                                      46 |
                                                                                                      47 | 49 | 79 | 80 | --------------------------------------------------------------------------------