How to use MooTools in iPhone code?

I need to use some of the date related libraries from MooTools, can I use it for my iPhone app?

If yes, then how can I add the MooTools library to my project?

— asked 6 years ago by Dev Priya
  • I also can't get Mootools 1.2.4 (Server Side) to scan. The parser gives up with a final message of 'Too many errors (57% scanned).'. Any ideas – is everyone else using another version of MooTools?

    By the way, am I the only one baffled that you don't get the same parser errors building an Android project as you do building an iPhone one? Appcelerator can't be using separate parsers in it's cross-compilers, can it?

    John S.

    — commented 5 years ago by John Storey
  • There was a big in Titanium Desktop that broke compiling when JSLint came back with an unexpected value. I submitted a fix for the issue and sent a pull request but I'm not sure if it was ever accepted.

    It's a very very easily fixed error in Titanium Desktop.

    — commented 5 years ago by Thomas Aylott

9 Answers

  • Contrary to what you just read. You can use MooTools. I can't speak for jQuery, but I don't think it would make sense since with jQuery, it's all about the DOM.

    Look under Server-Side Download

    I've used it for one of my Titanium projects and it works.

  • As far as the "Too many errors" problem, if you add this coment to the external library, Ti will ignore the errors. I started to use Thanasis Polychronakis' fix here:—want-to-use-googles-closure-tools, but looking at the code in compiler.js, it is just looking for the strings 'jQuery' and 'Sizzle' to skip the message. I added the comment to jQ mobile and it works….

    /* jQuery Sizzle - these are to fool the Ti compiler 
    into not reporting errors! */
  • @Bill- Does jQuery bear the same fate? :)

  • Hi Ben,

    Yes, same for jQuery. If you try Ti.include('jquery-1.4.2.min.js') (or whatever), for example, you'll get errors right away when running the app. It's looking for "window".

    I tried faking it out once by creating variables named window, document, and navigator, making each one an empty object literal. But I then it freaked out that it couldn't find some property of one of those objects – I realized I was playing a loser's game and gave up!



  • Good call, David. I'm sorry I missed the server-side Mootools, Dev.

  • So, I was giving this a shot with the mootools-1.2.4.-core-server.js file and it was yielding a pile of Javascript warnings during the js compiler scan…. finally it conks out completely with the error:

    [WARN] JavaScript compiler reported "Too many errors. (57% scanned)." at libs/mootools-1.2.4-core-server.js:629

    Most of the warnings have to do with lazy single-line conditionals that have no {}'s

    Sigh… Will see what I can make of it.

    Has anyone else had this problem or found a work around?


  • You can customize the Mootools packages here:

    Depending on what you're wanting, you can get around those errors. The errors happen because certain packages need the window DOM.

    I just started using Mootools to rewrite one of my apps in a more MVC-esque fashion. Mootool's class creation and helper methods (for arrays, strings, etc.) are great…so I recommend using it. It all gets compiled in the end anyway.

    My custom Mootools download includes: Core, Array, Function, Number, String, Hash, Class, and Class.Extra.

  • Hello Dev,

    Short answer: no.

    Longer answer: Mootools Date and Date.Extras require Mootools Core, and Mootools Core expects there to be a browser 'window' object available (and 'navigator', and 'document'). In other words, it expects to be imported into a web browser implementation of JavaScript. Therefore, it fails when imported into a Titanium 1.x mobile application.

    Some options:

    • Go through mootools Date and Date.Extras source code and rip out the parts you want, if it's not too difficult (I haven't looked at them.)
    • Have a look at alternative JavaScript date libraries which don't assume a web browser is present, such as date.js.

    BTW, in case you weren't sure how to import JavaScript files: Titanium.include('yourfile.js');.

    I hope this was nevertheless helpful!