Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few Options and events #61

Closed
wants to merge 6 commits into from
Closed

Few Options and events #61

wants to merge 6 commits into from

Conversation

lodev09
Copy link
Contributor

@lodev09 lodev09 commented May 15, 2014

I've added some options, methods and events that fixes some issues submitted by other users and also enhances the plugin.

Added events:

  • _onChange_ - This will trigger every time you typed in anything on the textarea. The event is triggered by keyup, callbacks from each menu buttons and native textarea.on('change', ... ) event

Added methods:

  • _hideButtons(name)_ - Completely hide the specified buttons by name. Using hidden class in boostrap.
  • _showButtons(name)_ - Opposite to hideButtons()
  • _parseContent()_ - Parsing the content is now separated, so you can always call this function to parse the textarea content.

Enhancement:

  • On showButtons, hideButtons, disableButtons and enableButtons methods, the name parameter can now be either an array or string

Fixes:

  • I've noticed on the current version, keyup is triggering _3x_ because of keypress and keydown events. I've commented these lines to avoid redundancy of keyup trigger.

Sample Implementation:

This code will output the preview in a separate div instead of the native preview button

// get the preview div
var $previewContainer = $('#post-md-preview');

// hide first
$previewContainer.hide();

// init
$("#post-md").markdown({
    autofocus: false,
    resize: 'vertical',
    height: 200,
    onShow: function(e) {
        e.hideButtons('cmdPreview');

                // in case you have default value
        e.change(e);
    },
    onChange: function(e) {
                // parse and get the parsed content
        var content = e.parseContent();

                // display preview :)
        if (content === '') $previewContainer.hide();
        else $previewContainer.show().html(content);
    }
});

@acrobat acrobat mentioned this pull request May 31, 2014
@acrobat
Copy link
Contributor

acrobat commented Jun 3, 2014

👍

It would be nice if we could pass the buttons what need to be hided by a data- property and check this in the init function. That way you are able to hide buttons onload of the editor

@lodev09
Copy link
Contributor Author

lodev09 commented Jun 3, 2014

👍 Yeah I will add that option later. 😄

@lodev09
Copy link
Contributor Author

lodev09 commented Jun 5, 2014

DONE! with few additional options and jquery hotkeys support too.

New Options:

  • footer - You can now write your own footer content together with the save button (if available)
  • hiddenButtons - array or string of button names to be hidden (called via hideButtons(...) method)
  • disabledButtons - array or string of button names to be disabled (called via disableButtons(...) method

New Buttons

  • Ordered List cmdListO (Ctrl+O) - Using numeric instead of hyphen -
  • Code cmdCode (Ctrl+K) - Button for code block
  • Quote cmdQuote (Ctrl+Q) - Button for quote block

jquery hotkeys support
https://github.com/jeresig/jquery.hotkeys
I've added the support for jquery hotkeys so user can assign a hotkey for each buttons (new property hotkey in the buttons object). Default buttons has already default hotkeys.

@lodev09
Copy link
Contributor Author

lodev09 commented Jun 5, 2014

Here is a plunk of my commits and also implemented jquery filedrop (my custom fork)

@acrobat
Copy link
Contributor

acrobat commented Jun 5, 2014

Looks good!

@lodev09 lodev09 closed this Jun 5, 2014
@lodev09 lodev09 reopened this Jun 5, 2014
@toopay
Copy link
Member

toopay commented Jun 8, 2014

@lodev09 can you re-base your fork with latest code so i can review this? Thanks.

@lodev09
Copy link
Contributor Author

lodev09 commented Jun 8, 2014

I'm new at github and I'm not sure if I did that right thing. I just copied over your latest code and add my changes to it. The current commit now is from your current code, hope that helps. :)

@acrobat
Copy link
Contributor

acrobat commented Jun 8, 2014

This is the way you can rebase against the current master:

# Add the remote, call it "upstream":

git remote add upstream https://github.com/toopay/bootstrap-markdown.git

# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:

git fetch upstream

# Make sure that you're on your master branch:

git checkout master

# Rewrite your master branch so that any commits of yours that
# aren't already in upstream/master are replayed on top of that
# other branch:

git rebase upstream/master

And just for future needs, this is the way you can sync your fork with the upstream repository! https://help.github.com/articles/syncing-a-fork

Added various options and event handlers
@lodev09
Copy link
Contributor Author

lodev09 commented Jun 8, 2014

I've done lots of commands and ended up resetting all my changes. Github is a bit confusing, I'm used with SVN. LOL

Anyway, I think line changes are based from the current code now.

@lodev09
Copy link
Contributor Author

lodev09 commented Jun 18, 2014

@toopay Do you have an update when this will be pulled? Thanks

@toopay
Copy link
Member

toopay commented Jun 22, 2014

@lodev09 Github still complaining "We can’t automatically merge this pull request." means this pull request require rebase...

@acrobat
Copy link
Contributor

acrobat commented Jun 23, 2014

@lodev09 just go through the steps from my last comment once again and then the PR should be ok! :)

Jeroen Thora and others added 4 commits June 23, 2014 18:22
Added various options and event handlers
Conflicts:
	js/bootstrap-markdown.js
@lodev09
Copy link
Contributor Author

lodev09 commented Jun 23, 2014

I deleted my fork and created a new one. Here is the new pull request

@lodev09 lodev09 closed this Jun 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants